本文整理汇总了C++中RegQueryInfoKeyW函数的典型用法代码示例。如果您正苦于以下问题:C++ RegQueryInfoKeyW函数的具体用法?C++ RegQueryInfoKeyW怎么用?C++ RegQueryInfoKeyW使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RegQueryInfoKeyW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: My_RegQueryInfoKeyW
BOOL My_RegQueryInfoKeyW()
{
HKEY hKey=NULL;
LPWSTR lpClass=NULL;
LPDWORD lpcbClass=NULL;
LPDWORD lpReserved=NULL;
LPDWORD lpcSubKeys=NULL;
LPDWORD lpcbMaxSubKeyLen=NULL;
LPDWORD lpcbMaxClassLen=NULL;
LPDWORD lpcValues=NULL;
LPDWORD lpcbMaxValueNameLen=NULL;
LPDWORD lpcbMaxValueLen=NULL;
LPDWORD lpcbSecurityDescriptor=NULL;
PFILETIME lpftLastWriteTime=NULL;
LONG returnVal_Real = NULL;
LONG returnVal_Intercepted = NULL;
DWORD error_Real = 0;
DWORD error_Intercepted = 0;
disableInterception();
returnVal_Real = RegQueryInfoKeyW (hKey,lpClass,lpcbClass,lpReserved,lpcSubKeys,lpcbMaxSubKeyLen,lpcbMaxClassLen,lpcValues,lpcbMaxValueNameLen,lpcbMaxValueLen,lpcbSecurityDescriptor,lpftLastWriteTime);
error_Real = GetLastError();
enableInterception();
returnVal_Intercepted = RegQueryInfoKeyW (hKey,lpClass,lpcbClass,lpReserved,lpcSubKeys,lpcbMaxSubKeyLen,lpcbMaxClassLen,lpcValues,lpcbMaxValueNameLen,lpcbMaxValueLen,lpcbSecurityDescriptor,lpftLastWriteTime);
error_Intercepted = GetLastError();
return ((returnVal_Real == returnVal_Intercepted) && (error_Real == error_Intercepted));
}
示例2: RegEnumKeyExX
// RegEnumKeyEx
// returns ERROR_NO_MORE_ITEMS or ERROR_SUCCESS
// if maxNameSize == 0, then we will compute it for you. Use it between calls on the same key for performance
inline LONG RegEnumKeyExX(HKEY hKey, DWORD dwIndex, std::wstring& outName, DWORD& maxNameSize)
{
FILETIME temp;
LONG ret;
std::vector<wchar_t> buf;
DWORD size;
outName.clear();
// get maximum subkey name length.
if(!maxNameSize)
{
if(ERROR_SUCCESS != (ret = RegQueryInfoKeyW(hKey, 0, 0, 0, 0, &maxNameSize, 0, 0, 0, 0, 0, 0)))
{
return ret;
}
maxNameSize += 2;// for safety
}
buf.resize(maxNameSize);
// make the call
size = static_cast<DWORD>(buf.size());
ret = RegEnumKeyExW(hKey, dwIndex, buf.data(), &size, 0, 0, 0, &temp);
if(ret == ERROR_SUCCESS)
{
outName = buf.data();
}
return ret;
}
示例3: GetProfileCount
static
BOOL
GetProfileCount(LPDWORD lpProfileCount)
{
HKEY hKey;
LONG lError;
*lpProfileCount = 0;
lError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"System\\CurrentControlSet\\Control\\IDConfigDB\\Hardware Profiles",
0,
KEY_READ,
&hKey);
if (lError != ERROR_SUCCESS)
return FALSE;
lError = RegQueryInfoKeyW(hKey, NULL, NULL, NULL, lpProfileCount,
NULL, NULL, NULL, NULL, NULL, NULL, NULL);
RegCloseKey(hKey);
if (lError != ERROR_SUCCESS)
return FALSE;
return TRUE;
}
示例4: subkeys
LONG CRegistryKey::GetValueCount(DWORD& rdwValueCount)
{
if (!m_hKey)
return 0; // the root key abstraction has only subkeys (hives)
return RegQueryInfoKeyW(m_hKey,NULL,NULL,NULL,NULL,NULL,NULL,&rdwValueCount,NULL,NULL,NULL,NULL);
}
示例5: initialize_disabled_joysticks_list
static void initialize_disabled_joysticks_list(HWND hwnd)
{
static const WCHAR disabled_str[] = {'d','i','s','a','b','l','e','d','\0'};
HKEY hkey, appkey;
DWORD values = 0;
HRESULT hr;
DWORD i;
SendDlgItemMessageW(hwnd, IDC_DISABLEDLIST, LB_RESETCONTENT, 0, 0);
/* Search for disabled joysticks */
get_app_key(&hkey, &appkey);
RegQueryInfoKeyW(hkey, NULL, NULL, NULL, NULL, NULL, NULL, &values, NULL, NULL, NULL, NULL);
for (i=0; i < values; i++)
{
DWORD name_len = MAX_PATH, data_len = MAX_PATH;
WCHAR buf_name[MAX_PATH + 9], buf_data[MAX_PATH];
hr = RegEnumValueW(hkey, i, buf_name, &name_len, NULL, NULL, (BYTE*) buf_data, &data_len);
if (SUCCEEDED(hr) && !lstrcmpW(disabled_str, buf_data))
SendDlgItemMessageW(hwnd, IDC_DISABLEDLIST, LB_ADDSTRING, 0, (LPARAM) buf_name);
}
if (hkey) RegCloseKey(hkey);
if (appkey) RegCloseKey(appkey);
}
示例6: InitIconOverlays
void InitIconOverlays(void)
{
HKEY hKey;
DWORD dwIndex, dwResult, dwSize;
WCHAR szName[MAX_PATH];
WCHAR szValue[100];
CLSID clsid;
IShellIconOverlayIdentifier * Overlay;
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
return;
if (RegQueryInfoKeyW(hKey, NULL, NULL, NULL, &dwResult, NULL, NULL, NULL, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
{
RegCloseKey(hKey);
return;
}
Handlers = (IShellIconOverlayIdentifier **)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwResult * sizeof(IShellIconOverlayIdentifier*));
if (!Handlers)
{
RegCloseKey(hKey);
return;
}
dwIndex = 0;
CoInitialize(0);
do
{
dwSize = sizeof(szName) / sizeof(WCHAR);
dwResult = RegEnumKeyExW(hKey, dwIndex, szName, &dwSize, NULL, NULL, NULL, NULL);
if (dwResult == ERROR_NO_MORE_ITEMS)
break;
if (dwResult == ERROR_SUCCESS)
{
dwSize = sizeof(szValue) / sizeof(WCHAR);
if (RegGetValueW(hKey, szName, NULL, RRF_RT_REG_SZ, NULL, szValue, &dwSize) == ERROR_SUCCESS)
{
CLSIDFromString(szValue, &clsid);
dwResult = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (LPVOID*)&Overlay);
if (dwResult == S_OK)
{
Handlers[NumIconOverlayHandlers] = Overlay;
NumIconOverlayHandlers++;
}
}
}
dwIndex++;
} while(1);
RegCloseKey(hKey);
}
示例7: MSACM_RegisterAllDrivers
/***********************************************************************
* MSACM_RegisterAllDrivers()
*/
void MSACM_RegisterAllDrivers(void)
{
static const WCHAR msacm32[] = {'m','s','a','c','m','3','2','.','d','l','l','\0'};
static const WCHAR msacmW[] = {'M','S','A','C','M','.'};
static const WCHAR drv32[] = {'d','r','i','v','e','r','s','3','2','\0'};
static const WCHAR sys[] = {'s','y','s','t','e','m','.','i','n','i','\0'};
static const WCHAR drvkey[] = {'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s',' ','N','T','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'D','r','i','v','e','r','s','3','2','\0'};
DWORD i, cnt, bufLen, lRet, type;
WCHAR buf[2048], valname[64], *name, *s;
FILETIME lastWrite;
HKEY hKey;
/* FIXME: What if the user edits system.ini while the program is running?
* Does Windows handle that? */
if (MSACM_pFirstACMDriverID) return;
lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, drvkey, 0, KEY_QUERY_VALUE, &hKey);
if (lRet == ERROR_SUCCESS) {
RegQueryInfoKeyW( hKey, 0, 0, 0, &cnt, 0, 0, 0, 0, 0, 0, 0);
for (i = 0; i < cnt; i++) {
bufLen = sizeof(buf) / sizeof(buf[0]);
lRet = RegEnumKeyExW(hKey, i, buf, &bufLen, 0, 0, 0, &lastWrite);
if (lRet != ERROR_SUCCESS) continue;
if (strncmpiW(buf, msacmW, sizeof(msacmW)/sizeof(msacmW[0]))) continue;
if (!(name = strchrW(buf, '='))) continue;
*name = 0;
MSACM_RegisterDriver(buf, name + 1, 0);
}
i = 0;
cnt = sizeof(valname) / sizeof(*valname);
bufLen = sizeof(buf);
while(RegEnumValueW(hKey, i, valname, &cnt, 0,
&type, (BYTE*)buf, &bufLen) == ERROR_SUCCESS){
if(!strncmpiW(valname, msacmW, sizeof(msacmW) / sizeof(*msacmW)))
MSACM_RegisterDriver(valname, buf, 0);
++i;
}
RegCloseKey( hKey );
}
if (GetPrivateProfileSectionW(drv32, buf, sizeof(buf)/sizeof(buf[0]), sys))
{
for(s = buf; *s; s += strlenW(s) + 1)
{
if (strncmpiW(s, msacmW, sizeof(msacmW)/sizeof(msacmW[0]))) continue;
if (!(name = strchrW(s, '='))) continue;
*name = 0;
MSACM_RegisterDriver(s, name + 1, 0);
*name = '=';
}
}
MSACM_ReorderDriversByPriority();
MSACM_RegisterDriver(msacm32, msacm32, 0);
}
示例8: Win32U_RegQueryInfoKey
LONG
Win32U_RegQueryInfoKey(HKEY keyName, // IN:
LPSTR className, // OUT:
LPDWORD classNameSize, // IN/OUT:
LPDWORD reserved, // IN: reserved
LPDWORD subKeysSize, // OUT:
LPDWORD maxSubKeyLen, // OUT:
LPDWORD maxClassLen, // OUT:
LPDWORD values, // OUT:
LPDWORD maxValueNameLen, // OUT:
LPDWORD maxValueLen, // OUT:
LPDWORD securityDescriptor, // OUT:
PFILETIME lpftLastWriteTime) // OUT:
{
LONG ret;
/* caller not interested in the actual data 'className' */
if (className == NULL) {
ret = RegQueryInfoKeyW(keyName, NULL, classNameSize, reserved,
subKeysSize, maxSubKeyLen, maxClassLen, values,
maxValueNameLen, maxValueLen, securityDescriptor,
lpftLastWriteTime);
} else {
// Receiving buffer for className.
utf16_t classNameW[REG_MAX_KEY_LEN] = { 0 };
DWORD classNameSizeW = ARRAYSIZE(classNameW);
ret = RegQueryInfoKeyW(keyName, classNameW, &classNameSizeW, reserved,
subKeysSize, maxSubKeyLen, maxClassLen, values,
maxValueNameLen, maxValueLen, securityDescriptor,
lpftLastWriteTime);
if (ret == ERROR_SUCCESS) {
if (!Win32UCodeSetUtf16leToUtf8(classNameW, classNameSizeW * 2,
className, classNameSize)) {
ret = ERROR_MORE_DATA;
}
}
}
return ret;
}
示例9: RegQueryInfoKeyW
bool WinRegKey::QueryInfo(LPDWORD lpcSubkeys)
{
LONG lRes;
lRes = RegQueryInfoKeyW(m_hKey, NULL, 0, 0, lpcSubkeys, 0, 0, 0, 0, 0, 0, 0);
if (ERROR_SUCCESS != lRes) {
TRACE_WINREG_ERROR("RegQueryInfoKeyW()==0x%x\n", lRes);
return false;
}
return true;
} //bool QueryInfo(LPDWORD lpcSubkeys);
示例10: enum_values
static HRESULT enum_values( HKEY root, const WCHAR *subkey, VARIANT *names, VARIANT *types, VARIANT *retval )
{
HKEY hkey = NULL;
HRESULT hr = S_OK;
BSTR *value_names = NULL;
DWORD count, buflen, len, *value_types = NULL;
LONG res, i = 0;
WCHAR *buf = NULL;
TRACE("%p, %s\n", root, debugstr_w(subkey));
if ((res = RegOpenKeyExW( root, subkey, 0, KEY_QUERY_VALUE, &hkey ))) goto done;
if ((res = RegQueryInfoKeyW( hkey, NULL, NULL, NULL, NULL, NULL, NULL, &count, &buflen, NULL, NULL, NULL )))
goto done;
hr = E_OUTOFMEMORY;
if (!(buf = heap_alloc( (buflen + 1) * sizeof(WCHAR) ))) goto done;
if (!(value_names = heap_alloc( count * sizeof(BSTR) ))) goto done;
if (!(value_types = heap_alloc( count * sizeof(DWORD) ))) goto done;
hr = S_OK;
for (;;)
{
len = buflen + 1;
res = RegEnumValueW( hkey, i, buf, &len, NULL, &value_types[i], NULL, NULL );
if (res == ERROR_NO_MORE_ITEMS)
{
if (i) res = ERROR_SUCCESS;
break;
}
if (res) break;
if (!(value_names[i] = SysAllocString( buf )))
{
for (i--; i >= 0; i--) SysFreeString( value_names[i] );
hr = ERROR_OUTOFMEMORY;
break;
}
i++;
}
if (hr == S_OK && !res)
{
hr = to_bstr_array( value_names, i, names );
if (hr == S_OK) hr = to_i4_array( value_types, i, types );
}
done:
set_variant( VT_UI4, res, NULL, retval );
RegCloseKey( hkey );
heap_free( value_names );
heap_free( value_types );
heap_free( buf );
return hr;
}
示例11: RegQueryInfoKeyW
LONG CRegistryKey::GetLastWriteTime(SYSTEMTIME &st)
{
FILETIME ftLocal,ft;
LONG nError = RegQueryInfoKeyW(m_hKey,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,&ft);
if (nError == ERROR_SUCCESS)
{
FileTimeToLocalFileTime(&ft,&ftLocal);
FileTimeToSystemTime(&ftLocal,&st);
}
return nError;
}
示例12: NS_ENSURE_TRUE
NS_IMETHODIMP
nsWindowsRegKey::GetValueCount(PRUint32 *result)
{
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
DWORD numValues;
LONG rv = RegQueryInfoKeyW(mKey, NULL, NULL, NULL, NULL, NULL, NULL,
&numValues, NULL, NULL, NULL, NULL);
NS_ENSURE_STATE(rv == ERROR_SUCCESS);
*result = numValues;
return NS_OK;
}
示例13: defined
bool WinRegKey::QueryInfo(LPDWORD lpcSubkeys)
{
#if defined(MEDIASDK_USE_REGISTRY) || (!defined(MEDIASDK_UWP_LOADER) && !defined(MEDIASDK_UWP_PROCTABLE))
LONG lRes;
lRes = RegQueryInfoKeyW(m_hKey, NULL, 0, 0, lpcSubkeys, 0, 0, 0, 0, 0, 0, 0);
if (ERROR_SUCCESS != lRes) {
TRACE_WINREG_ERROR("RegQueryInfoKeyW()==0x%x\n", lRes);
return false;
}
return true;
#else
return false;
#endif
} //bool QueryInfo(LPDWORD lpcSubkeys);
示例14: RegQueryInfoKeyW
NS_IMETHODIMP
nsWindowsRegKey::GetValueCount(uint32_t* aResult)
{
if (NS_WARN_IF(!mKey)) {
return NS_ERROR_NOT_INITIALIZED;
}
DWORD numValues;
LONG rv = RegQueryInfoKeyW(mKey, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, &numValues, nullptr, nullptr,
nullptr, nullptr);
if (rv != ERROR_SUCCESS) {
return NS_ERROR_FAILURE;
}
*aResult = numValues;
return NS_OK;
}
示例15: DEVENUM_IEnumMoniker_Skip
static HRESULT WINAPI DEVENUM_IEnumMoniker_Skip(IEnumMoniker *iface, ULONG celt)
{
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
DWORD special_subkeys = 0;
TRACE("(%p)->(%d)\n", iface, celt);
/* Before incrementing, check if there are any more values to run through.
Some programs use the Skip() function to get the number of devices */
if(This->special_hkey)
RegQueryInfoKeyW(This->special_hkey, NULL, NULL, NULL, &special_subkeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
if((This->index + celt) >= This->subkey_cnt + special_subkeys)
{
return S_FALSE;
}
This->index += celt;
return S_OK;
}