本文整理汇总了C++中RegOpenKeyW函数的典型用法代码示例。如果您正苦于以下问题:C++ RegOpenKeyW函数的具体用法?C++ RegOpenKeyW怎么用?C++ RegOpenKeyW使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RegOpenKeyW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UltraEdit
UltraEdit()
{
installed_ = false;
HKEY key;
LPCWSTR szUltraEditHive = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\uedit32.exe";
LONG lRet = RegOpenKeyW(HKEY_LOCAL_MACHINE, szUltraEditHive, &key);
if( lRet == ERROR_SUCCESS )
{
DWORD dwType = REG_SZ;
DWORD dwSize = sizeof(szPath_);
lRet = RegQueryValueExW(key, L"Path", NULL, &dwType, (LPBYTE)szPath_, &dwSize);
if( lRet == ERROR_SUCCESS ) installed_ = true;
}
}
示例2: FindMimeFromData
/***********************************************************************
* FindMimeFromData ([email protected])
*
* Determines the Multipurpose Internet Mail Extensions (MIME) type from the data provided.
*/
HRESULT WINAPI FindMimeFromData(LPBC pBC, LPCWSTR pwzUrl, LPVOID pBuffer,
DWORD cbSize, LPCWSTR pwzMimeProposed, DWORD dwMimeFlags,
LPWSTR* ppwzMimeOut, DWORD dwReserved)
{
TRACE("(%p,%s,%p,%d,%s,0x%x,%p,0x%x)\n", pBC, debugstr_w(pwzUrl), pBuffer, cbSize,
debugstr_w(pwzMimeProposed), dwMimeFlags, ppwzMimeOut, dwReserved);
if(dwMimeFlags)
WARN("dwMimeFlags=%08x\n", dwMimeFlags);
if(dwReserved)
WARN("dwReserved=%d\n", dwReserved);
/* pBC seams to not be used */
if(!ppwzMimeOut || (!pwzUrl && !pBuffer))
return E_INVALIDARG;
if(pwzMimeProposed || pBuffer)
return find_mime_from_buffer(pBuffer, cbSize, pwzMimeProposed, ppwzMimeOut);
if(pwzUrl) {
HKEY hkey;
DWORD res, size;
LPCWSTR ptr;
WCHAR mime[64];
static const WCHAR wszContentType[] =
{'C','o','n','t','e','n','t',' ','T','y','p','e','\0'};
ptr = strrchrW(pwzUrl, '.');
if(!ptr)
return E_FAIL;
res = RegOpenKeyW(HKEY_CLASSES_ROOT, ptr, &hkey);
if(res != ERROR_SUCCESS)
return HRESULT_FROM_WIN32(res);
size = sizeof(mime);
res = RegQueryValueExW(hkey, wszContentType, NULL, NULL, (LPBYTE)mime, &size);
RegCloseKey(hkey);
if(res != ERROR_SUCCESS)
return HRESULT_FROM_WIN32(res);
*ppwzMimeOut = CoTaskMemAlloc(size);
memcpy(*ppwzMimeOut, mime, size);
return S_OK;
}
return E_FAIL;
}
示例3: EditPlus
EditPlus()
{
installed_ = false;
HKEY key;
LPCWSTR szEditPlusHive = L"Software\\ES-Computing\\EditPlus 3\\Install";
LONG lRet = RegOpenKeyW(HKEY_CURRENT_USER, szEditPlusHive, &key);
if( lRet == ERROR_SUCCESS )
{
DWORD dwType = REG_SZ;
DWORD dwSize = sizeof(szPath_);
lRet = RegQueryValueExW(key, L"Path", NULL, &dwType, (LPBYTE)szPath_, &dwSize);
if( lRet == ERROR_SUCCESS ) installed_ = true;
}
}
示例4: GetKeyW
static HKEY GetKeyW(LPCWSTR appname, BOOL * closekey, BOOL fCreate) {
HKEY key = 0;
WCHAR achName[MAX_PATH];
#if !MMPROFILECACHE
*closekey = TRUE;
#else
UINT n;
ATOM atm;
*closekey = FALSE;
//
// See if we have already used this key
//
atm = FindAtomW(appname);
if (atm != 0) {
// Atom exists... search the table for it.
for (n=0; n<keyscached; ++n) {
if (akeyatoms[n] == atm) {
DPF2(("(W)Found existing key for %ls\n", appname));
return ahkey[n];
}
}
}
DPF2(("(W)No key found for %ls\n", appname));
#endif
lstrcpyW(achName, KEYNAME );
lstrcatW(achName, appname);
if ((!fCreate && RegOpenKeyW(ROOTKEY, achName, &key) == ERROR_SUCCESS)
|| (fCreate && RegCreateKeyW(ROOTKEY, achName, &key) == ERROR_SUCCESS)) {
#if MMPROFILECACHE
if (keyscached < KEYSCACHED
&& (atm = AddAtomW(appname))) {
// Add this key to the cache array
akeyatoms[keyscached] = atm;
ahkey[keyscached] = key;
DPF1(("Adding key %ls to cache array in position %d\n", appname, keyscached));
++keyscached;
} else {
DPF2(("Not adding key to cache array\n"));
*closekey = TRUE;
}
#endif
}
return(key);
}
示例5: NotepadPlusPlus
NotepadPlusPlus()
{
installed_ = false;
HKEY key;
LPCWSTR szNotepadPlusPlusHive = L"SOFTWARE\\Notepad++";
LONG lRet = RegOpenKeyW(HKEY_LOCAL_MACHINE, szNotepadPlusPlusHive, &key);
if( lRet == ERROR_SUCCESS )
{
DWORD dwType = REG_SZ;
DWORD dwSize = sizeof(szPath_);
lRet = RegQueryValueExW(key, NULL, NULL, &dwType, (LPBYTE)szPath_, &dwSize);
if( lRet == ERROR_SUCCESS ) installed_ = true;
}
}
示例6: get_drive_map
/* retrieve a map of drives that should be displayed */
static DWORD get_drive_map(void)
{
static const WCHAR policiesW[] = {'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'P','o','l','i','c','i','e','s','\\',
'E','x','p','l','o','r','e','r',0};
static const WCHAR nodrivesW[] = {'N','o','D','r','i','v','e','s',0};
static DWORD drive_mask;
static BOOL init_done = FALSE;
if (!init_done)
{
DWORD type, size, data, mask = 0;
HKEY hkey;
if (!RegOpenKeyW( HKEY_LOCAL_MACHINE, policiesW, &hkey ))
{
size = sizeof(data);
if (!RegQueryValueExW( hkey, nodrivesW, NULL, &type, (LPBYTE)&data, &size ) && type == REG_DWORD)
mask |= data;
RegCloseKey( hkey );
}
if (!RegOpenKeyW( HKEY_CURRENT_USER, policiesW, &hkey ))
{
size = sizeof(data);
if (!RegQueryValueExW( hkey, nodrivesW, NULL, &type, (LPBYTE)&data, &size ) && type == REG_DWORD)
mask |= data;
RegCloseKey( hkey );
}
drive_mask = mask;
init_done = TRUE;
}
return GetLogicalDrives() & ~drive_mask;
}
示例7: DEVENUM_IEnumMoniker_Next
static HRESULT WINAPI DEVENUM_IEnumMoniker_Next(IEnumMoniker *iface, ULONG celt, IMoniker **rgelt,
ULONG *pceltFetched)
{
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
WCHAR buffer[MAX_PATH + 1];
LONG res;
ULONG fetched = 0;
MediaCatMoniker * pMoniker;
TRACE("(%p)->(%d, %p, %p)\n", iface, celt, rgelt, pceltFetched);
while (fetched < celt)
{
if(This->index+fetched < This->subkey_cnt)
res = RegEnumKeyW(This->hkey, This->index+fetched, buffer, sizeof(buffer) / sizeof(WCHAR));
else if(This->special_hkey)
res = RegEnumKeyW(This->special_hkey, This->index+fetched-This->subkey_cnt, buffer, sizeof(buffer) / sizeof(WCHAR));
else
break;
if (res != ERROR_SUCCESS)
{
break;
}
pMoniker = DEVENUM_IMediaCatMoniker_Construct();
if (!pMoniker)
return E_OUTOFMEMORY;
if (RegOpenKeyW(This->index+fetched < This->subkey_cnt ? This->hkey : This->special_hkey,
buffer, &pMoniker->hkey) != ERROR_SUCCESS)
{
IMoniker_Release(&pMoniker->IMoniker_iface);
break;
}
rgelt[fetched] = &pMoniker->IMoniker_iface;
fetched++;
}
This->index += fetched;
TRACE("-- fetched %d\n", fetched);
if (pceltFetched)
*pceltFetched = fetched;
if (fetched != celt)
return S_FALSE;
else
return S_OK;
}
示例8: RegOpenKeyEx
void CVstPluginManager::EnumerateDirectXDMOs()
//--------------------------------------------
{
HKEY hkEnum;
WCHAR keyname[128];
LONG cr = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\classes\\DirectShow\\MediaObjects\\Categories\\f3602b3f-0592-48df-a4cd-674721e7ebeb", 0, KEY_READ, &hkEnum);
DWORD index = 0;
while (cr == ERROR_SUCCESS)
{
if ((cr = RegEnumKeyW(hkEnum, index, keyname, CountOf(keyname))) == ERROR_SUCCESS)
{
CLSID clsid;
std::wstring formattedKey = std::wstring(L"{") + std::wstring(keyname) + std::wstring(L"}");
if(Util::StringToCLSID(formattedKey, clsid))
{
HKEY hksub;
formattedKey = std::wstring(L"software\\classes\\DirectShow\\MediaObjects\\") + std::wstring(keyname);
if (RegOpenKeyW(HKEY_LOCAL_MACHINE, formattedKey.c_str(), &hksub) == ERROR_SUCCESS)
{
WCHAR name[64];
DWORD datatype = REG_SZ;
DWORD datasize = sizeof(name);
if(ERROR_SUCCESS == RegQueryValueExW(hksub, nullptr, 0, &datatype, (LPBYTE)name, &datasize))
{
mpt::String::SetNullTerminator(name);
StringFromGUID2(clsid, keyname, 100);
VSTPluginLib *plug = new (std::nothrow) VSTPluginLib(mpt::PathString::FromNative(keyname), mpt::PathString::FromNative(name));
if(plug != nullptr)
{
pluginList.push_back(plug);
plug->pluginId1 = kDmoMagic;
plug->pluginId2 = clsid.Data1;
plug->category = VSTPluginLib::catDMO;
#ifdef DMO_LOG
Log(mpt::String::PrintW(L"Found \"%1\" clsid=%2\n", plug->libraryName, plug->dllPath));
#endif
}
}
RegCloseKey(hksub);
}
}
}
index++;
}
if (hkEnum) RegCloseKey(hkEnum);
}
示例9: MSIREG_OpenUninstallKey
UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create)
{
UINT rc;
WCHAR keypath[0x200];
TRACE("%s\n",debugstr_w(szProduct));
sprintfW(keypath,szUninstall_fmt,szProduct);
if (create)
rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
else
rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
return rc;
}
示例10: RegOpenKey
NTSTATUS
RegOpenKey(
IN PHANDLE hKey,
IN PWCHAR szKeyName
)
{
UNICODE_STRING usKeyName;
RtlInitUnicodeString(&usKeyName, szKeyName);
return
RegOpenKeyW(
hKey,
&usKeyName
);
}
示例11: get_url_encoding
/**************************************************************************
* UrlMkGetSessionOption ([email protected])
*/
static BOOL get_url_encoding(HKEY root, DWORD *encoding)
{
DWORD size = sizeof(DWORD), res, type;
HKEY hkey;
static const WCHAR wszUrlEncoding[] = {'U','r','l','E','n','c','o','d','i','n','g',0};
res = RegOpenKeyW(root, internet_settings_keyW, &hkey);
if(res != ERROR_SUCCESS)
return FALSE;
res = RegQueryValueExW(hkey, wszUrlEncoding, NULL, &type, (LPBYTE)encoding, &size);
RegCloseKey(hkey);
return res == ERROR_SUCCESS;
}
示例12: open_config_key
static HKEY open_config_key(void)
{
HKEY hkey, ret;
DWORD res;
static const WCHAR wine_keyW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e',0};
/* @@ Wine registry key: HKCU\Software\Wine\$config_key */
res = RegOpenKeyW(HKEY_CURRENT_USER, wine_keyW, &hkey);
if(res != ERROR_SUCCESS)
return NULL;
res = RegOpenKeyA(hkey, addon->config_key, &ret);
RegCloseKey(hkey);
return res == ERROR_SUCCESS ? ret : NULL;
}
示例13: get_protocol_cf
static HRESULT get_protocol_cf(LPCWSTR schema, DWORD schema_len, CLSID *pclsid, IClassFactory **ret)
{
WCHAR str_clsid[64];
HKEY hkey = NULL;
DWORD res, type, size;
CLSID clsid;
LPWSTR wszKey;
HRESULT hres;
static const WCHAR wszProtocolsKey[] =
{'P','R','O','T','O','C','O','L','S','\\','H','a','n','d','l','e','r','\\'};
static const WCHAR wszCLSID[] = {'C','L','S','I','D',0};
wszKey = heap_alloc(sizeof(wszProtocolsKey)+(schema_len+1)*sizeof(WCHAR));
memcpy(wszKey, wszProtocolsKey, sizeof(wszProtocolsKey));
memcpy(wszKey + sizeof(wszProtocolsKey)/sizeof(WCHAR), schema, (schema_len+1)*sizeof(WCHAR));
res = RegOpenKeyW(HKEY_CLASSES_ROOT, wszKey, &hkey);
heap_free(wszKey);
if(res != ERROR_SUCCESS) {
TRACE("Could not open protocol handler key\n");
return MK_E_SYNTAX;
}
size = sizeof(str_clsid);
res = RegQueryValueExW(hkey, wszCLSID, NULL, &type, (LPBYTE)str_clsid, &size);
RegCloseKey(hkey);
if(res != ERROR_SUCCESS || type != REG_SZ) {
WARN("Could not get protocol CLSID res=%d\n", res);
return MK_E_SYNTAX;
}
hres = CLSIDFromString(str_clsid, &clsid);
if(FAILED(hres)) {
WARN("CLSIDFromString failed: %08x\n", hres);
return hres;
}
if(pclsid)
*pclsid = clsid;
if(!ret)
return S_OK;
hres = CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)ret);
return SUCCEEDED(hres) ? S_OK : MK_E_SYNTAX;
}
示例14: swprintf_s
/// <summary>
/// Fill minimal required driver registry entry
/// </summary>
/// <param name="svcName">Driver service name</param>
/// <param name="path">Driver path</param>
/// <returns>Status code</returns>
LSTATUS DriverControl::PrepareDriverRegEntry( const std::wstring& svcName, const std::wstring& path )
{
HKEY key1, key2;
DWORD dwType = 1;
LSTATUS status = 0;
WCHAR wszLocalPath[MAX_PATH] = { 0 };
swprintf_s( wszLocalPath, ARRAYSIZE( wszLocalPath ), L"\\??\\%s", path.c_str() );
status = RegOpenKeyW( HKEY_LOCAL_MACHINE, L"system\\CurrentControlSet\\Services", &key1 );
if (status)
return status;
status = RegCreateKeyW( key1, svcName.c_str(), &key2 );
if (status)
{
RegCloseKey( key1 );
return status;
}
status = RegSetValueExW(
key2, L"ImagePath", 0, REG_SZ,
reinterpret_cast<const BYTE*>(wszLocalPath),
static_cast<DWORD>(sizeof( WCHAR )* (wcslen( wszLocalPath ) + 1))
);
if (status)
{
RegCloseKey( key2 );
RegCloseKey( key1 );
return status;
}
status = RegSetValueExW( key2, L"Type", 0, REG_DWORD, reinterpret_cast<const BYTE*>(&dwType), sizeof( dwType ) );
if (status)
{
RegCloseKey( key2 );
RegCloseKey( key1 );
return status;
}
RegCloseKey( key2 );
RegCloseKey( key1 );
return status;
}
示例15: RegOpenKeyA
LONG WINAPI
RegOpenKeyA(
IN HKEY hKey,
IN LPCSTR lpSubKey,
OUT PHKEY phkResult)
{
PWSTR lpSubKeyW;
LONG rc;
lpSubKeyW = MultiByteToWideChar(lpSubKey);
if (!lpSubKeyW)
return ERROR_OUTOFMEMORY;
rc = RegOpenKeyW(hKey, lpSubKeyW, phkResult);
free(lpSubKeyW);
return rc;
}