kodi
WIN32Util.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "HDRStatus.h"
12 #include "URL.h"
13 #include "utils/Geometry.h"
14 
15 #include <vector>
16 
17 #include <dxgi1_5.h>
18 
19 #define BONJOUR_EVENT ( WM_USER + 0x100 ) // Message sent to the Window when a Bonjour event occurs.
20 #define BONJOUR_BROWSER_EVENT ( WM_USER + 0x110 )
21 #define TRAY_ICON_NOTIFY ( WM_USER + 0x120 )
22 
24 {
25  int majorVersion;
26  int minorVersion;
27  bool valid;
28  std::string version;
29 };
30 
31 class CURL; // forward declaration
32 
34 {
35 public:
36  CWIN32Util(void);
37  virtual ~CWIN32Util(void);
38 
39  static char FirstDriveFromMask (ULONG unitmask);
40  static int GetDriveStatus(const std::string &strPath, bool bStatusEx=false);
41  static bool XBMCShellExecute(const std::string &strPath, bool bWaitForScriptExit=false);
42  static std::string GetResInfoString();
43  static int GetDesktopColorDepth();
44  static size_t GetSystemMemorySize();
45 
46  static std::string GetSystemPath();
47  static std::string GetProfilePath(const bool platformDirectories);
48  static std::string UncToSmb(const std::string &strPath);
49  static std::string SmbToUnc(const std::string &strPath);
50  static bool AddExtraLongPathPrefix(std::wstring& path);
51  static bool RemoveExtraLongPathPrefix(std::wstring& path);
52  static std::wstring ConvertPathToWin32Form(const std::string& pathUtf8);
53  static std::wstring ConvertPathToWin32Form(const CURL& url);
54  static inline __time64_t fileTimeToTimeT(const __int64 ftimei64)
55  {
56  // FILETIME is 100-nanoseconds from 00:00:00 UTC 01 Jan 1601
57  // __time64_t is seconds from 00:00:00 UTC 01 Jan 1970
58  return (ftimei64 - 116444736000000000) / 10000000;
59  }
60  static __time64_t fileTimeToTimeT(const FILETIME& ftimeft);
61  static __time64_t fileTimeToTimeT(const LARGE_INTEGER& ftimeli);
62  static HRESULT ToggleTray(const char cDriveLetter='\0');
63  static HRESULT EjectTray(const char cDriveLetter='\0');
64  static HRESULT CloseTray(const char cDriveLetter='\0');
65  static BOOL IsCurrentUserLocalAdministrator();
66 
67 #ifdef TARGET_WINDOWS_DESKTOP
68  static std::string GetSpecialFolder(int csidl);
69  static LONG UtilRegGetValue( const HKEY hKey, const char *const pcKey, DWORD *const pdwType, char **const ppcBuffer, DWORD *const pdwSizeBuff, const DWORD dwSizeAdd );
70  static bool UtilRegOpenKeyEx( const HKEY hKeyParent, const char *const pcKey, const REGSAM rsAccessRights, HKEY *hKey, const bool bReadX64= false );
71  static bool GetFocussedProcess(std::string &strProcessFile);
72 #endif // TARGET_WINDOWS_DESKTOP
73  static void CropSource(CRect& src, CRect& dst, CRect target, UINT rotation = 0);
74 
75  static std::string WUSysMsg(DWORD dwError);
76  static bool SetThreadLocalLocale(bool enable = true);
77 
78  // HDR display support
79  static HDR_STATUS ToggleWindowsHDR(DXGI_MODE_DESC& modeDesc);
80  static HDR_STATUS GetWindowsHDRStatus();
81  static bool GetSystemSdrWhiteLevel(const std::wstring& gdiDeviceName, float* sdrWhiteLevel);
82 
83  static void PlatformSyslog();
84 
85  static VideoDriverInfo GetVideoDriverInfo(const UINT vendorId, const std::wstring& driverDesc);
86  static std::wstring GetDisplayFriendlyName(const std::wstring& GdiDeviceName);
93  static bool SetThreadName(const HANDLE handle, const std::string& name);
101  static bool IsDriverVersionAtLeast(const std::string& version1, const std::string& version2);
102 };
Definition: XHandle.h:21
Definition: URL.h:21
Definition: WIN32Util.h:33
Definition: WIN32Util.h:23
Definition: PlatformDefs.h:72