21#if !defined WIN32_LEAN_AND_MEAN
22# define WIN32_LEAN_AND_MEAN
27#include <registry.hxx>
36 wchar_t dummy[] = L
"";
37 int rc = RegCreateKeyExW(
38 RootKey, KeyName, 0, dummy, REG_OPTION_NON_VOLATILE, KEY_WRITE,
nullptr, &hSubKey,
nullptr);
40 if (ERROR_SUCCESS == rc)
43 hSubKey, ValueName, 0, REG_SZ,
reinterpret_cast<const BYTE*
>(
Value),
44 static_cast<DWORD
>((wcslen(
Value) + 1) *
sizeof(*
Value)));
49 return (ERROR_SUCCESS == rc);
57 int rc = RegOpenKeyExW(
64 if ( rc == ERROR_FILE_NOT_FOUND )
67 if (ERROR_SUCCESS == rc)
72 rc = RegQueryInfoKeyW(
73 hKey,
nullptr,
nullptr,
nullptr,
nullptr,
75 nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr);
79 SubKey =
static_cast<wchar_t*
>(
80 _alloca(nMaxSubKeyLen*
sizeof(
wchar_t)));
82 while (ERROR_SUCCESS == rc)
84 DWORD nLen = nMaxSubKeyLen;
91 nullptr,
nullptr,
nullptr,
nullptr);
93 if (ERROR_NO_MORE_ITEMS == rc)
95 rc = RegDeleteKeyW(RootKey, KeyName);
98 else if (rc == ERROR_SUCCESS)
109 return (ERROR_SUCCESS == rc);
119 LONG rc = RegOpenKeyExW(RootKey, KeyName, 0, KEY_READ, &hKey);
121 if (ERROR_SUCCESS == rc)
125 rc = RegQueryInfoKeyW(hKey,
nullptr,
nullptr,
nullptr, &nSubKeys,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr);
128 bResult = (nSubKeys > 0);
131 return (ERROR_SUCCESS == rc);
138 LPOLESTR wszCLSID =
nullptr;
139 StringFromCLSID(clsid, &wszCLSID);
141 std::wstring sResult = wszCLSID;
144 CoTaskMemFree(wszCLSID) ;
154 int rc = RegOpenKeyExW(
161 if (ERROR_SUCCESS == rc)
163 DWORD dwBytes = dwBufLen *
sizeof(*pszData);
164 rc = RegQueryValueExW(
165 hKey, ValueName,
nullptr,
nullptr,
reinterpret_cast<LPBYTE
>(pszData),&dwBytes);
170 return (ERROR_SUCCESS == rc);
Filepath_t ClsidToString(const CLSID &clsid)
Converts a GUID to its string representation.
bool HasSubkeysRegistryKey(HKEY RootKey, const Filepath_char_t *KeyName, bool &bResult)
May be used to determine if the specified registry key has subkeys The function returns true on succe...
bool QueryRegistryKey(HKEY RootKey, const Filepath_char_t *KeyName, const Filepath_char_t *ValueName, Filepath_char_t *pszData, DWORD dwBufLen)
Get the content of a specific key.
bool DeleteRegistryKey(HKEY RootKey, const Filepath_char_t *KeyName)
Deletes the specified registry key and all of its subkeys Returns true on success.
bool SetRegistryKey(HKEY RootKey, const Filepath_char_t *KeyName, const Filepath_char_t *ValueName, const Filepath_char_t *Value)
Sets a value of the specified registry key, an empty ValueName sets the default value Returns true on...