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


C++ RegOpenKeyExW函数代码示例

本文整理汇总了C++中RegOpenKeyExW函数的典型用法代码示例。如果您正苦于以下问题:C++ RegOpenKeyExW函数的具体用法?C++ RegOpenKeyExW怎么用?C++ RegOpenKeyExW使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了RegOpenKeyExW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: IsPrefetchDisabledViaService

/**
 * Determines if the registry is disabled via the service or not.
 * 
 * @return true if prefetch is disabled
 *         false if prefetch is not disabled or an error occurred.
*/
bool IsPrefetchDisabledViaService()
{
  // We don't need to return false when we don't have MOZ_MAINTENANCE_SERVICE
  // defined.  The reason is because another product installed that has it
  // defined may have cleared our prefetch for us.  There is no known way
  // to figure out which prefetch files are associated with which apps
  // because of the prefetch hash.  So we disable all of them that start
  // with FIREFOX.
  HKEY baseKey;
  LONG retCode = RegOpenKeyExW(HKEY_LOCAL_MACHINE, 
                               L"SOFTWARE\\Mozilla\\MaintenanceService", 0,
                               KEY_READ | KEY_WOW64_64KEY, &baseKey);
  if (retCode != ERROR_SUCCESS) {
    return false;
  }
  DWORD disabledValue = 0;
  DWORD disabledValueSize = sizeof(DWORD);
  RegQueryValueExW(baseKey, L"FFPrefetchDisabled", 0, NULL,
                   reinterpret_cast<LPBYTE>(&disabledValue),
                   &disabledValueSize);
  RegCloseKey(baseKey);
  return disabledValue == 1;
}
开发者ID:catlee,项目名称:mozilla-central,代码行数:29,代码来源:nsBrowserApp.cpp

示例2: GetLaunchOnStartup

static BOOL 
GetLaunchOnStartup()
{
	
    WCHAR regPath[MAX_PATH], exePath[MAX_PATH];	
    BOOL result = FALSE;
    HKEY regkey;

    if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_READ, &regkey) == ERROR_SUCCESS) {

        if (GetRegistryValue(regkey, L"OpenVPN-GUI", regPath, MAX_PATH) &&
            GetModuleFileNameW(NULL, exePath, MAX_PATH)) {
            if (_wcsicmp(regPath, exePath) == 0)
                result = TRUE;
        }

        RegCloseKey(regkey);

    }
	
    return result;

}
开发者ID:ffes,项目名称:openvpn-gui,代码行数:23,代码来源:localization.c

示例3: IsUacSupported

BOOL IsUacSupported()
{
    HKEY hkey;
    DWORD value = 1, size = sizeof (DWORD);

    if (!IsVistaOrLater())
    {
        return FALSE;
    }

    if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
                      L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", 0, KEY_READ, &hkey) == ERROR_SUCCESS)
    {
        if (RegQueryValueExW(hkey, L"EnableLUA", 0, 0, (LPBYTE) &value, &size) != ERROR_SUCCESS)
        {
            value = 1;
        }

        RegCloseKey (hkey);
    }

    return value != 0;
}
开发者ID:BenjaminHuangD,项目名称:Barium,代码行数:23,代码来源:Uac.cpp

示例4: GetDefaultBrowserAppModelID

  /*
  * Retrieve the app model id of the firefox metro browser.
  *
  * @aPathBuffer Buffer to fill
  * @aCharLength Length of buffer to fill in characters
  */
  bool GetDefaultBrowserAppModelID(WCHAR* aIDBuffer, long aCharLength)
  {
    if (!aIDBuffer || aCharLength <= 0)
      return false;

    memset(aIDBuffer, 0, (sizeof(WCHAR)*aCharLength));
    static const WCHAR* kDefaultMetroBrowserIDPathKey = L"FirefoxURL";

    HKEY key;
    if (RegOpenKeyExW(HKEY_CLASSES_ROOT, kDefaultMetroBrowserIDPathKey,
                      0, KEY_READ, &key) != ERROR_SUCCESS) {
      return false;
    }
    DWORD len = aCharLength * sizeof(WCHAR);
    memset(aIDBuffer, 0, len);
    if (RegQueryValueExW(key, L"AppUserModelID", nullptr, nullptr,
                         (LPBYTE)aIDBuffer, &len) != ERROR_SUCCESS || !len) {
      RegCloseKey(key);
      return false;
    }
    RegCloseKey(key);
    return true;
  }
开发者ID:DragonZX,项目名称:fdm2,代码行数:29,代码来源:updatehelper.cpp

示例5: defined

bool WinRegistryKey::exists(const std::string& name)
{
	bool exists = false;
	HKEY hKey;
#if defined(POCO_WIN32_UTF8)
	std::wstring usubKey;
	Poco::UnicodeConverter::toUTF16(_subKey, usubKey);
	if (RegOpenKeyExW(_hRootKey, usubKey.c_str(), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
	{
		std::wstring uname;
		Poco::UnicodeConverter::toUTF16(name, uname);
		exists = RegQueryValueExW(hKey, uname.c_str(), NULL, NULL, NULL, NULL) == ERROR_SUCCESS;
		RegCloseKey(hKey);
	}
#else
	if (RegOpenKeyEx(_hRootKey, _subKey.c_str(), 0, KEY_READ, &hKey) != ERROR_SUCCESS)
	{
		exists = RegQueryValueEx(hKey, name.c_str(), NULL, NULL, NULL, NULL) == ERROR_SUCCESS;
		RegCloseKey(hKey);
	}
#endif
	return exists;
}
开发者ID:beneon,项目名称:MITK,代码行数:23,代码来源:WinRegistryKey.cpp

示例6: ExtUnassign

void CDlgFileAssoc::ExtUnassign(LPWSTR extName) {

	HKEY hKey;
	DWORD len = 100;
	wchar_t buf[100];

	if (RegOpenKeyExW(HKEY_CLASSES_ROOT, extName, 0, 0, &hKey) == ERROR_SUCCESS) {

		if (RegQueryValueExW(hKey, L"Nitrogen backup", NULL, NULL, (BYTE*)buf, &len) == ERROR_SUCCESS) {	

			RegSetValueExW(hKey, NULL, 0, REG_SZ, (BYTE*)buf, len);
			RegDeleteValueW(hKey, L"Nitrogen backup");
	
		} else {

			RegDeleteValueW(hKey, NULL);
	
		}
	
		RegCloseKey(hKey);
	}

}
开发者ID:dps123,项目名称:nitrogenS100,代码行数:23,代码来源:cdlgfileassoc.cpp

示例7: GetRegistryString

StdCopyStrBuf GetRegistryString(const char *szSubKey, const char *szValueName)
{
	HKEY ckey;

	// Open the key
	if (RegOpenKeyExW(HKEY_CURRENT_USER, GetWideChar(szSubKey), 0, KEY_READ, &ckey)!=ERROR_SUCCESS)
		return StdCopyStrBuf();

	// Get the value
	DWORD dwValSize = 128;
	BYTE *sValue = new BYTE[dwValSize];
	while(true)
	{
		DWORD valtype;
		switch(RegQueryValueExW(ckey, GetWideChar(szValueName), NULL, &valtype,
			sValue, &dwValSize))
		{
		case ERROR_SUCCESS:
			RegCloseKey(ckey);
			if (valtype == REG_SZ)
			{
				StdCopyStrBuf nrv(reinterpret_cast<wchar_t*>(sValue));
				delete[] sValue;
				return nrv;
			} else {
		default:
				delete[] sValue;
				return StdCopyStrBuf();
			}
			break;
		case ERROR_MORE_DATA:
			delete[] sValue;
			sValue = new BYTE[dwValSize];
			break;
		}
	}
}
开发者ID:sarah-russell12,项目名称:openclonk,代码行数:37,代码来源:StdRegistry.cpp

示例8: mailCommand

// Retrieve the commandline for the default mail client. It contains a
// placeholder %1 for the URL. The default key used below is the
// command line for the mailto: shell command.
static inline QString mailCommand()
{
    enum { BufferSize = sizeof(wchar_t) * MAX_PATH };

    const wchar_t mailUserKey[] = L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\mailto\\UserChoice";

    wchar_t command[MAX_PATH] = {0};
    // Check if user has set preference, otherwise use default.
    HKEY handle;
    QString keyName;
    if (!RegOpenKeyEx(HKEY_CURRENT_USER, mailUserKey, 0, KEY_READ, &handle)) {
        DWORD bufferSize = BufferSize;
        if (!RegQueryValueEx(handle, L"Progid", 0, 0, reinterpret_cast<unsigned char*>(command), &bufferSize))
            keyName = QString::fromWCharArray(command);
        RegCloseKey(handle);
    }
    if (keyName.isEmpty())
        keyName = QStringLiteral("mailto");
    keyName += QStringLiteral("\\Shell\\Open\\Command");
    if (debug)
        qDebug() << __FUNCTION__ << "keyName=" << keyName;
    command[0] = 0;
    if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, (const wchar_t*)keyName.utf16(), 0, KEY_READ, &handle)) {
        DWORD bufferSize = BufferSize;
        RegQueryValueEx(handle, L"", 0, 0, reinterpret_cast<unsigned char*>(command), &bufferSize);
        RegCloseKey(handle);
    }
    if (!command[0])
        return QString();
#ifndef Q_OS_WINCE
    wchar_t expandedCommand[MAX_PATH] = {0};
    return ExpandEnvironmentStrings(command, expandedCommand, MAX_PATH) ?
           QString::fromWCharArray(expandedCommand) : QString::fromWCharArray(command);
#else
    return QString();
#endif
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:40,代码来源:qwindowsservices.cpp

示例9: RegCopyData

void RegCopyData(HKEY hKeyIn, HKEY hKeyOut) {

	int index = 0;
	DWORD lenName = 200;
	DWORD lenData = 300;
	wchar_t bufName[200];
	BYTE bufData[300];
	DWORD typ;

	while (RegEnumValueW(hKeyIn, index, (LPWSTR)bufName, &lenName, NULL, &typ, (LPBYTE)bufData, &lenData) == ERROR_SUCCESS) {
		
		RegSetValueExW(hKeyOut, bufName, 0, typ, bufData, lenData);

		lenName = 200;
		lenData = 200;
		index++;
	}

	index = 0;
	while (RegEnumKeyExW(hKeyIn, index, (LPWSTR)bufName, &lenName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {

		HKEY hNewKeyIn;
		if (RegOpenKeyExW(hKeyIn, bufName, 0, 0, &hNewKeyIn) == ERROR_SUCCESS) {
			HKEY hNewKeyOut;
			if (RegCreateKeyEx(hKeyOut, bufName, 0, NULL, REG_OPTION_NON_VOLATILE, 0, NULL, &hNewKeyOut, NULL) == ERROR_SUCCESS) {
				RegCopyData(hNewKeyIn, hNewKeyOut);
				RegCloseKey(hNewKeyOut);
			}
			RegCloseKey(hNewKeyIn);
		}
		lenName = 200;
		index++;
	
	}


}
开发者ID:dps123,项目名称:nitrogenS100,代码行数:37,代码来源:cdlgfileassoc.cpp

示例10: ViewDlg_RestoreDefaults

static VOID
ViewDlg_RestoreDefaults(HWND hwndDlg)
{
    HWND hwndTreeView = GetDlgItem(hwndDlg, IDC_VIEW_TREEVIEW);

    for (INT i = 0; i < s_ViewTreeEntryCount; ++i)
    {
        // ignore if the type is group
        VIEWTREE_ENTRY *pEntry = &s_ViewTreeEntries[i];
        if (pEntry->dwType == AETYPE_GROUP)
            continue;

        // set default value on registry
        HKEY hKey;
        if (RegOpenKeyExW(HKEY(pEntry->hkeyRoot), pEntry->szRegPath,
                          0, KEY_WRITE, &hKey) != ERROR_SUCCESS)
        {
            continue;
        }
        RegSetValueExW(hKey, pEntry->szValueName, 0, REG_DWORD,
                       LPBYTE(&pEntry->dwDefaultValue), sizeof(DWORD));
        RegCloseKey(hKey);

        // update check status
        pEntry->bChecked = (pEntry->dwCheckedValue == pEntry->dwDefaultValue);

        // update the image
        TV_ITEM Item;
        ZeroMemory(&Item, sizeof(Item));
        Item.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
        Item.hItem = pEntry->hItem;
        Item.iImage = Item.iSelectedImage = ViewTree_GetImage(pEntry);
        TreeView_SetItem(hwndTreeView, &Item);
    }

    PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
}
开发者ID:Moteesh,项目名称:reactos,代码行数:37,代码来源:view.cpp

示例11: IsUnpromptedElevation

/**
 * Determines if the the system's elevation type allows
 * unprmopted elevation.  This may not 100% reflect reality since
 * a reboot is necessary to change the UAC level.
 *
 * @param isUnpromptedElevation Out parameter which specifies if unprompted
 *                              elevation is allowed.
 * @return TRUE if the value was obtained successfully.
*/
BOOL
IsUnpromptedElevation(BOOL &isUnpromptedElevation)
{
  LPCWSTR UACBaseRegKey =
    L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System";
  HKEY baseKey;
  LONG retCode = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
                               UACBaseRegKey, 0,
                               KEY_READ, &baseKey);
  if (retCode != ERROR_SUCCESS) {
    return FALSE;
  }

  DWORD enabled, consent, secureDesktop;
  BOOL success = GetDWORDValue(baseKey, L"EnableLUA", enabled);
  success = success &&
            GetDWORDValue(baseKey, L"ConsentPromptBehaviorAdmin", consent);
  success = success &&
            GetDWORDValue(baseKey, L"PromptOnSecureDesktop", secureDesktop);
  isUnpromptedElevation = enabled && !consent && !secureDesktop;

  RegCloseKey(baseKey);
  return success;
}
开发者ID:Nebelhom,项目名称:mozilla-central,代码行数:33,代码来源:updatehelper.cpp

示例12: readRegistry

SEXP readRegistry(SEXP call, SEXP op, SEXP args, SEXP env)
{
    SEXP ans;
    HKEY hive, hkey;
    LONG res;
    const wchar_t *key;
    int maxdepth, view;
    REGSAM acc = KEY_READ;

    args = CDR(args);
    if(!isString(CAR(args)) || LENGTH(CAR(args)) != 1)
	error(_("invalid '%s' value"),  "key");
    key = filenameToWchar(STRING_ELT(CAR(args), 0), 0);
    if(!isString(CADR(args)) || LENGTH(CADR(args)) != 1)
	error(_("invalid '%s' value"),  "hive");
    maxdepth = asInteger(CADDR(args));
    if(maxdepth == NA_INTEGER || maxdepth < 1)
	error(_("invalid '%s' value"),  "maxdepth");
    hive = find_hive(CHAR(STRING_ELT(CADR(args), 0)));
    view = asInteger(CADDDR(args));
    /* Or KEY_READ with KEY_WOW64_64KEY or KEY_WOW64_32KEY to
       explicitly access the 64- or 32- bit registry view.  See
       http://msdn.microsoft.com/en-us/library/aa384129(VS.85).aspx
    */
    if(view == 2) acc |= KEY_WOW64_32KEY;
    else if(view == 3) acc |= KEY_WOW64_64KEY;

    res = RegOpenKeyExW(hive, key, 0, acc, &hkey);
    if (res == ERROR_FILE_NOT_FOUND)
	error(_("Registry key '%ls' not found"), key);
    if (res != ERROR_SUCCESS)
	error("RegOpenKeyEx error code %d: '%s'", (int) res, formatError(res));
    ans = readRegistryKey(hkey, maxdepth, view);
    RegCloseKey(hkey);
    return ans;
}
开发者ID:Bgods,项目名称:r-source,代码行数:36,代码来源:registry.c

示例13: GetGinaPath

static
BOOL
GetGinaPath(
    OUT LPWSTR Path,
    IN DWORD Len)
{
    LONG Status;
    DWORD Type, Size;
    HKEY hKey;

    Status = RegOpenKeyExW(
        HKEY_LOCAL_MACHINE,
        L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
        0,
        KEY_QUERY_VALUE,
        &hKey);
    if (Status != ERROR_SUCCESS)
    {
        /* Default value */
        wcsncpy(Path, L"msgina.dll", Len);
        return TRUE;
    }

    Size = Len * sizeof(WCHAR);
    Status = RegQueryValueExW(
        hKey,
        L"GinaDLL",
        NULL,
        &Type,
        (LPBYTE)Path,
        &Size);
    if (Status != ERROR_SUCCESS || Type != REG_SZ || Size == 0)
        wcsncpy(Path, L"msgina.dll", Len);
    RegCloseKey(hKey);
    return TRUE;
}
开发者ID:amaneureka,项目名称:reactos,代码行数:36,代码来源:wlx.c

示例14: win32_find_msysgit_in_registry

int win32_find_msysgit_in_registry(struct win32_path *root, const HKEY hieve, const wchar_t *key)
{
	HKEY hKey;
	DWORD dwType = REG_SZ;
	DWORD dwSize = MAX_PATH;

	assert(root);

	root->len = 0;
	if (RegOpenKeyExW(hieve, key, 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS) {
		if (RegQueryValueExW(hKey, L"InstallLocation", NULL, &dwType, (LPBYTE)&root->path, &dwSize) == ERROR_SUCCESS) {
			// InstallLocation points to the root of the msysgit directory
			if (dwSize + 4 > MAX_PATH) {// 4 = wcslen(L"etc\\")
				giterr_set(GITERR_OS, "Cannot locate the system's msysgit directory - path too long");
				return -1;
			}
			wcscat(root->path, L"etc\\");
			root->len = (DWORD)wcslen(root->path) + 1;
		}
	}
	RegCloseKey(hKey);

	return root->len ? 0 : GIT_ENOTFOUND;
}
开发者ID:duralog,项目名称:node-sencillo,代码行数:24,代码来源:findfile.c

示例15: sizeof

BOOL CVSSMgr::GetDefaultDatabase(LPWSTR FilePathBuf,IN OUT PULONG BufLen)
{
	BOOL	bRet = FALSE;
	HKEY	hKey;
	DWORD	dwType;
	DWORD   dwValue = (*BufLen) * sizeof(WCHAR);

	LONG hr = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
						L"SOFTWARE\\Microsoft\\SourceSafe",
						0,
						KEY_READ,
						&hKey);
	if(SUCCEEDED(hr))
	{
		hr = RegQueryValueExW(hKey,L"Current Database",0,&dwType,(LPBYTE)FilePathBuf,&dwValue);
		if(SUCCEEDED(hr))
		{
			*BufLen = dwValue/sizeof(WCHAR);
			bRet = TRUE;
		}
		RegCloseKey(hKey);
	}
	return bRet;
}
开发者ID:aldertotori,项目名称:ShellOverlay,代码行数:24,代码来源:VSSMgr.cpp


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