123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- #ifndef BASE_WIN_WIN_UTIL_H_
- #define BASE_WIN_WIN_UTIL_H_
- #include <stdint.h>
- #include "base/win/windows_types.h"
- #include <string>
- #include <vector>
- #include "base/base_export.h"
- #include "base/macros.h"
- #include "base/strings/string_piece.h"
- struct IPropertyStore;
- struct _tagpropertykey;
- using PROPERTYKEY = _tagpropertykey;
- namespace base {
- struct NativeLibraryLoadError;
- namespace win {
- inline uint32_t HandleToUint32(HANDLE h) {
-
-
-
-
- return static_cast<uint32_t>(reinterpret_cast<uintptr_t>(h));
- }
- inline HANDLE Uint32ToHandle(uint32_t h) {
- return reinterpret_cast<HANDLE>(
- static_cast<uintptr_t>(static_cast<int32_t>(h)));
- }
- BASE_EXPORT bool GetUserSidString(std::wstring* user_sid);
- BASE_EXPORT bool UserAccountControlIsEnabled();
- BASE_EXPORT bool SetBooleanValueForPropertyStore(
- IPropertyStore* property_store,
- const PROPERTYKEY& property_key,
- bool property_bool_value);
- BASE_EXPORT bool SetStringValueForPropertyStore(
- IPropertyStore* property_store,
- const PROPERTYKEY& property_key,
- const wchar_t* property_string_value);
- BASE_EXPORT bool SetClsidForPropertyStore(IPropertyStore* property_store,
- const PROPERTYKEY& property_key,
- const CLSID& property_clsid_value);
- BASE_EXPORT bool SetAppIdForPropertyStore(IPropertyStore* property_store,
- const wchar_t* app_id);
- BASE_EXPORT bool AddCommandToAutoRun(HKEY root_key,
- const std::wstring& name,
- const std::wstring& command);
- BASE_EXPORT bool RemoveCommandFromAutoRun(HKEY root_key,
- const std::wstring& name);
- BASE_EXPORT bool ReadCommandFromAutoRun(HKEY root_key,
- const std::wstring& name,
- std::wstring* command);
- BASE_EXPORT void SetShouldCrashOnProcessDetach(bool crash);
- BASE_EXPORT bool ShouldCrashOnProcessDetach();
- BASE_EXPORT void SetAbortBehaviorForCrashReporting();
- BASE_EXPORT bool IsWindows10TabletMode(HWND hwnd);
- BASE_EXPORT bool IsTabletDevice(std::string* reason, HWND hwnd);
- BASE_EXPORT bool IsDeviceUsedAsATablet(std::string* reason);
- BASE_EXPORT bool IsKeyboardPresentOnSlate(HWND hwnd, std::string* reason);
- #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(struct_name, member) \
- offsetof(struct_name, member) + \
- (sizeof static_cast<struct_name*>(NULL)->member)
- BASE_EXPORT bool IsEnrolledToDomain();
- BASE_EXPORT bool IsDeviceRegisteredWithManagement();
- BASE_EXPORT bool IsUser32AndGdi32Available();
- BASE_EXPORT bool GetLoadedModulesSnapshot(HANDLE process,
- std::vector<HMODULE>* snapshot);
- BASE_EXPORT void EnableFlicks(HWND hwnd);
- BASE_EXPORT void DisableFlicks(HWND hwnd);
- BASE_EXPORT bool IsProcessPerMonitorDpiAware();
- BASE_EXPORT void EnableHighDPISupport();
- BASE_EXPORT std::wstring WStringFromGUID(REFGUID rguid);
- BASE_EXPORT bool PinUser32(NativeLibraryLoadError* error = nullptr);
- BASE_EXPORT void* GetUser32FunctionPointer(
- const char* function_name,
- NativeLibraryLoadError* error = nullptr);
- BASE_EXPORT std::wstring GetWindowObjectName(HANDLE handle);
- BASE_EXPORT bool IsRunningUnderDesktopName(WStringPiece desktop_name);
- BASE_EXPORT bool IsCurrentSessionRemote();
- class BASE_EXPORT ScopedDomainStateForTesting {
- public:
- ScopedDomainStateForTesting(bool state);
- ~ScopedDomainStateForTesting();
- private:
- bool initial_state_;
- DISALLOW_COPY_AND_ASSIGN(ScopedDomainStateForTesting);
- };
- class BASE_EXPORT ScopedDeviceRegisteredWithManagementForTesting {
- public:
- ScopedDeviceRegisteredWithManagementForTesting(bool state);
- ~ScopedDeviceRegisteredWithManagementForTesting();
- private:
- bool initial_state_;
- DISALLOW_COPY_AND_ASSIGN(ScopedDeviceRegisteredWithManagementForTesting);
- };
- }
- }
- #endif
|