当前位置: 首页>>代码示例>>C++>>正文


C++ RegQueryInfoKeyW函数代码示例

本文整理汇总了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));
}
开发者ID:IFGHou,项目名称:Holodeck,代码行数:27,代码来源:RegQueryInfoKeyW.cpp

示例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;
  }
开发者ID:thenfour,项目名称:LibCC,代码行数:34,代码来源:winapi.hpp

示例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;
}
开发者ID:crank123,项目名称:reactos,代码行数:27,代码来源:hardprof.c

示例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);
}
开发者ID:GYGit,项目名称:reactos,代码行数:7,代码来源:RegistryKey.cpp

示例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);
}
开发者ID:PatroxGaurab,项目名称:wine,代码行数:28,代码来源:main.c

示例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);
}
开发者ID:Nevermore2015,项目名称:reactos,代码行数:59,代码来源:folders.cpp

示例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);
}
开发者ID:AlexSteel,项目名称:wine,代码行数:61,代码来源:internal.c

示例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;
}
开发者ID:dontsueme,项目名称:vmware-view-open-client,代码行数:42,代码来源:win32uRegistry.c

示例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);
开发者ID:373137461,项目名称:rtmp_streamer_for_windows,代码行数:12,代码来源:mfx_win_reg_key.cpp

示例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;
}
开发者ID:ZoloZiak,项目名称:reactos,代码行数:53,代码来源:reg.c

示例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;
}
开发者ID:GYGit,项目名称:reactos,代码行数:13,代码来源:RegistryKey.cpp

示例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;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:13,代码来源:nsWindowsRegKey.cpp

示例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);
开发者ID:lu-zero,项目名称:mfx_dispatch,代码行数:16,代码来源:mfx_win_reg_key.cpp

示例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;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:18,代码来源:nsWindowsRegKey.cpp

示例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;
}
开发者ID:hoangduit,项目名称:reactos,代码行数:21,代码来源:mediacatenum.c


注:本文中的RegQueryInfoKeyW函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。