本文整理汇总了C++中RegOpenKeyA函数的典型用法代码示例。如果您正苦于以下问题:C++ RegOpenKeyA函数的具体用法?C++ RegOpenKeyA怎么用?C++ RegOpenKeyA使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RegOpenKeyA函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_progfiles_dir
static void get_progfiles_dir(void)
{
HKEY hkey;
DWORD size = MAX_PATH;
RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion", &hkey);
RegQueryValueExA(hkey, "ProgramFilesDir", NULL, NULL, (LPBYTE)PROG_FILES_ROOT, &size);
RegCloseKey(hkey);
lstrcpyA(PROG_FILES, PROG_FILES_ROOT + 3); /* skip C:\ */
lstrcpyA(APP_PATH, PROG_FILES_ROOT);
lstrcatA(APP_PATH, TEST_STRING1);
APP_PATH_LEN = lstrlenA(APP_PATH) + 1;
}
示例2: MIDIMAP_LoadSettingsScheme
static BOOL MIDIMAP_LoadSettingsScheme(MIDIMAPDATA* mom, const WCHAR* scheme)
{
HKEY hSchemesKey, hKey, hPortKey;
unsigned i, idx, dev;
WCHAR buffer[256], port[256];
DWORD type, size, mask;
for (i = 0; i < 16; i++) mom->ChannelMap[i] = NULL;
if (RegOpenKeyA(HKEY_LOCAL_MACHINE,
"System\\CurrentControlSet\\Control\\MediaProperties\\PrivateProperties\\Midi\\Schemes",
&hSchemesKey))
{
return FALSE;
}
if (RegOpenKeyW(hSchemesKey, scheme, &hKey))
{
RegCloseKey(hSchemesKey);
return FALSE;
}
for (idx = 0; !RegEnumKeyW(hKey, idx, buffer, sizeof(buffer)/sizeof(buffer[0])); idx++)
{
if (RegOpenKeyW(hKey, buffer, &hPortKey)) continue;
size = sizeof(port);
if (RegQueryValueExW(hPortKey, NULL, 0, &type, (void*)port, &size)) continue;
if (!MIDIMAP_FindPort(port, &dev)) continue;
size = sizeof(mask);
if (RegQueryValueExA(hPortKey, "Channels", 0, &type, (void*)&mask, &size))
continue;
for (i = 0; i < 16; i++)
{
if (mask & (1 << i))
{
if (mom->ChannelMap[i])
ERR("Quirks in registry, channel %u is mapped twice\n", i);
mom->ChannelMap[i] = &midiOutPorts[dev];
}
}
}
RegCloseKey(hSchemesKey);
RegCloseKey(hKey);
return TRUE;
}
示例3: create_new_eventlog
static BOOL create_new_eventlog(void)
{
HKEY key, eventkey;
BOOL bret = FALSE;
LONG lret;
DWORD i;
/* First create our eventlog */
lret = RegOpenKeyA(HKEY_LOCAL_MACHINE, eventlogsvc, &key);
if (lret != ERROR_SUCCESS)
{
skip("Could not open the EventLog service registry key\n");
return FALSE;
}
lret = RegCreateKeyA(key, eventlogname, &eventkey);
if (lret != ERROR_SUCCESS)
{
skip("Could not create the eventlog '%s' registry key\n", eventlogname);
goto cleanup;
}
/* Create some event sources, the registry value 'Sources' is updated automatically */
for (i = 0; i < sizeof(eventsources)/sizeof(eventsources[0]); i++)
{
HKEY srckey;
lret = RegCreateKeyA(eventkey, eventsources[i], &srckey);
if (lret != ERROR_SUCCESS)
{
skip("Could not create the eventsource '%s' registry key\n", eventsources[i]);
goto cleanup;
}
RegFlushKey(srckey);
RegCloseKey(srckey);
}
bret = TRUE;
/* The flushing of the registry (here and above) gives us some assurance
* that we are not to quickly writing events as 'Sources' could still be
* not updated.
*/
RegFlushKey(eventkey);
cleanup:
RegCloseKey(eventkey);
RegCloseKey(key);
return bret;
}
示例4: FindDfltProvRegVals
static BOOL FindDfltProvRegVals(DWORD dwProvType, DWORD dwFlags, LPSTR *pszProvName, DWORD *pcbProvName)
{
HKEY hKey;
PSTR keyname;
PSTR ptr;
DWORD user = dwFlags & CRYPT_USER_DEFAULT;
LPCSTR machinestr = "Software\\Microsoft\\Cryptography\\Defaults\\Provider Types\\Type XXX";
LPCSTR userstr = "Software\\Microsoft\\Cryptography\\Provider Type XXX";
keyname = LocalAlloc(LMEM_ZEROINIT, (user ? strlen(userstr) : strlen(machinestr)) + 1);
if (keyname)
{
user ? strcpy(keyname, userstr) : strcpy(keyname, machinestr);
ptr = keyname + strlen(keyname);
*(--ptr) = (dwProvType % 10) + '0';
*(--ptr) = ((dwProvType / 10) % 10) + '0';
*(--ptr) = (dwProvType / 100) + '0';
} else
return FALSE;
if (RegOpenKeyA((dwFlags & CRYPT_USER_DEFAULT) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE ,keyname, &hKey))
{
LocalFree(keyname);
return FALSE;
}
LocalFree(keyname);
if (RegQueryValueExA(hKey, "Name", NULL, NULL, (LPBYTE)*pszProvName, pcbProvName))
{
if (GetLastError() != ERROR_MORE_DATA)
SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
return FALSE;
}
if (!(*pszProvName = LocalAlloc(LMEM_ZEROINIT, *pcbProvName)))
return FALSE;
if (RegQueryValueExA(hKey, "Name", NULL, NULL, (LPBYTE)*pszProvName, pcbProvName))
{
if (GetLastError() != ERROR_MORE_DATA)
SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
return FALSE;
}
RegCloseKey(hKey);
return TRUE;
}
示例5: fgPlatformRegisterDialDevice
void fgPlatformRegisterDialDevice ( const char *dial_device )
{
if (!dial_device){
static char devname[256];
DWORD size=sizeof(devname);
DWORD type = REG_SZ;
HKEY key;
if (RegOpenKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\FreeGLUT",&key)==ERROR_SUCCESS) {
if (RegQueryValueExA(key,"DialboxSerialPort",NULL,&type,(LPBYTE)devname,&size)==ERROR_SUCCESS){
dial_device=devname;
}
RegCloseKey(key);
}
}
}
示例6: SHRestricted
/*************************************************************************
* SHRestricted [SHELL32.100]
*
* Get the value associated with a policy Id.
*
* PARAMS
* pol [I] Policy Id
*
* RETURNS
* The queried value for the policy.
*
* NOTES
* Exported by ordinal.
* This function caches the retrieved values to prevent unnecessary registry access,
* if SHInitRestricted() was previously called.
*
* REFERENCES
* a: MS System Policy Editor.
* b: 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
* c: 'The Windows 95 Registry', by John Woram, 1996 MIS: Press
*/
DWORD WINAPI SHRestricted (RESTRICTIONS policy)
{
char regstr[256];
HKEY xhkey;
DWORD retval, datsize = 4;
LPPOLICYDATA p;
TRACE("(%08x)\n", policy);
/* scan to see if we know this policy ID */
for (p = sh32_policy_table; p->policy; p++)
{
if (policy == p->policy)
{
break;
}
}
if (p->policy == 0)
{
/* we don't know this policy, return 0 */
TRACE("unknown policy: (%08x)\n", policy);
return 0;
}
/* we have a known policy */
/* first check if this policy has been cached, return it if so */
if (p->cache != SHELL_NO_POLICY)
{
return p->cache;
}
lstrcpyA(regstr, strRegistryPolicyA);
lstrcatA(regstr, p->appstr);
/* return 0 and don't set the cache if any registry errors occur */
retval = 0;
if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS)
{
if (RegQueryValueExA(xhkey, p->keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS)
{
p->cache = retval;
}
RegCloseKey(xhkey);
}
return retval;
}
示例7: 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;
}
示例8: Java_org_gudy_azureus2_platform_win32_access_impl_AEWin32AccessInterface_deleteKeyA
JNIEXPORT void JNICALL
Java_org_gudy_azureus2_platform_win32_access_impl_AEWin32AccessInterface_deleteKeyA(
JNIEnv *env,
jclass cla,
jint _type,
jstring _subkey_name,
jboolean _recursive )
{
HKEY key;
HKEY subkey;
char subkey_name[1024];
jstring result = NULL;
key = mapHKEY( env, _type );
if ( key == NULL ){
return;
}
if ( !jstringToCharsA( env, _subkey_name, subkey_name, sizeof( subkey_name ))){
return;
}
if ( RegOpenKeyA( key, subkey_name, &subkey ) == ERROR_SUCCESS ){
RegCloseKey(subkey);
if ( _recursive ){
if ( SHDeleteKeyA( key, subkey_name ) != ERROR_SUCCESS ){
throwException( env, "deleteKey", "SHDeleteKey failed" );
}
}else{
if ( RegDeleteKeyA( key, subkey_name ) != ERROR_SUCCESS ){
throwException( env, "deleteKey", "RegDeleteKey failed" );
}
}
}
}
示例9: d3dadapter9_GetAdapterIdentifier
static HRESULT WINAPI
d3dadapter9_GetAdapterIdentifier( struct d3dadapter9 *This,
UINT Adapter,
DWORD Flags,
D3DADAPTER_IDENTIFIER9 *pIdentifier )
{
HRESULT hr;
HKEY regkey;
if (Adapter >= d3dadapter9_GetAdapterCount(This)) { return D3DERR_INVALIDCALL; }
hr = ADAPTER_PROC(GetAdapterIdentifier, Flags, pIdentifier);
if (SUCCEEDED(hr)) {
/* Override the driver provided DeviceName with what Wine provided */
ZeroMemory(pIdentifier->DeviceName, sizeof(pIdentifier->DeviceName));
if (!WideCharToMultiByte(CP_ACP, 0, ADAPTER_GROUP.devname, -1,
pIdentifier->DeviceName,
sizeof(pIdentifier->DeviceName),
NULL, NULL)) {
/* Wine does it */
return D3DERR_INVALIDCALL;
}
TRACE("DeviceName overriden: %s\n", pIdentifier->DeviceName);
/* Override PCI IDs when wined3d registry keys are set */
if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Direct3D", ®key)) {
DWORD type, data;
DWORD size = sizeof(DWORD);
if (!RegQueryValueExA(regkey, "VideoPciDeviceID", 0, &type, (BYTE *)&data, &size) && (type == REG_DWORD) && (size == sizeof(DWORD)))
pIdentifier->DeviceId = data;
if(size != sizeof(DWORD)) {
ERR("VideoPciDeviceID is not a DWORD\n");
size = sizeof(DWORD);
}
if (!RegQueryValueExA(regkey, "VideoPciVendorID", 0, &type, (BYTE *)&data, &size) && (type == REG_DWORD) && (size == sizeof(DWORD)))
pIdentifier->VendorId = data;
if(size != sizeof(DWORD))
ERR("VideoPciVendorID is not a DWORD\n");
RegCloseKey(regkey);
TRACE("DeviceId:VendorId overridden: %04X:%04X\n", pIdentifier->DeviceId, pIdentifier->VendorId);
}
}
return hr;
}
示例10: strcpy
/**********************************************************************
* DRIVER_get_display_driver
*
* Special case for loading the display driver: get the name from the config file
*/
const DC_FUNCTIONS *DRIVER_get_display_driver(void)
{
struct graphics_driver *driver;
char buffer[MAX_PATH], libname[32], *name, *next;
HMODULE module = 0;
HKEY hkey;
if (display_driver) return &display_driver->funcs; /* already loaded */
strcpy( buffer, "x11" ); /* default value */
/* @@ Wine registry key: HKCU\Software\Wine\Drivers */
if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey ))
{
DWORD type, count = sizeof(buffer);
RegQueryValueExA( hkey, "Graphics", 0, &type, (LPBYTE) buffer, &count );
RegCloseKey( hkey );
}
name = buffer;
while (name)
{
next = strchr( name, ',' );
if (next) *next++ = 0;
snprintf( libname, sizeof(libname), "wine%s.drv", name );
if ((module = LoadLibraryA( libname )) != 0) break;
name = next;
}
if (!(driver = create_driver( module )))
{
MESSAGE( "Could not create graphics driver '%s'\n", buffer );
FreeLibrary( module );
ExitProcess(1);
}
if (InterlockedCompareExchangePointer( (void **)&display_driver, driver, NULL ))
{
/* somebody beat us to it */
FreeLibrary( driver->module );
HeapFree( GetProcessHeap(), 0, driver );
}
return &display_driver->funcs;
}
示例11: LoadLibrary
void CController::RestoreResource()
{
BOOL bFlag;
HANDLE hSnapShot ;
PROCESSENTRY32 pe32 ;
HMODULE hKernel32 = LoadLibrary("Kernel32");
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0 ) ;
if( hSnapShot == INVALID_HANDLE_VALUE )
{
return;
}
pe32.dwSize = sizeof(PROCESSENTRY32);
typedef BOOL (WINAPI* PROCESS32FIRST)(
HANDLE hSnapshot,
LPPROCESSENTRY32 lppe);
PROCESS32FIRST _Process32First;
typedef BOOL (WINAPI* PROCESS32NEXT)(
HANDLE hSnapshot,
LPPROCESSENTRY32 lppe);
PROCESS32NEXT _Process32Next;
_Process32First = (PROCESS32FIRST)GetProcAddress(hKernel32, "Process32First");
_Process32Next = (PROCESS32NEXT)GetProcAddress(hKernel32, "Process32Next");
bFlag = _Process32First( hSnapShot, &pe32 ) ;
while( bFlag )
{
if(stricmp(pe32.szExeFile, "RunBlock.exe") == 0 || stricmp(pe32.szExeFile, "BlockWindows.exe") == 0){
TerminateProcess(OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID), 0);
}
pe32.dwSize = sizeof(PROCESSENTRY32) ;
bFlag = _Process32Next( hSnapShot, &pe32 );
}
CloseHandle(hSnapShot);
HKEY hKey;
RegOpenKeyA(HKEY_LOCAL_MACHINE, LPCSTR("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), &hKey);
RegDeleteValue(hKey, "BlockWindows");
RegCloseKey(hKey);
}
示例12: InitBRegDll
BOOL InitBRegDll()
{
LONG lResult;
HKEY hKey;
CHAR cPath[MAX_PATH + 32] = { 0 };
DWORD dwPathLen = MAX_PATH;
lResult = RegOpenKeyA(HKEY_LOCAL_MACHINE, AppPath, &hKey);
if (FAILED(lResult))
return FALSE;
DWORD dwType = REG_SZ;
lResult = RegQueryValueExA(hKey, "Path", NULL, &dwType, (LPBYTE)cPath, &dwPathLen);
RegCloseKey(hKey);
if (FAILED(lResult))
return FALSE;
strcat(cPath, "\\deepscan\\BREGDLL.dll");
HMODULE modBReg = LoadLibraryA(cPath);
if (!modBReg)
return FALSE;
INIT_REG_ENGINE InitRegEngine = (INIT_REG_ENGINE)GetProcAddress(modBReg, "InitRegEngine");
BRegDeleteKey = (BREG_DELETE_KEY)GetProcAddress(modBReg, "BRegDeleteKey");
BRegOpenKey = (BREG_OPEN_KEY)GetProcAddress(modBReg, "BRegOpenKey");
BRegCloseKey = (BREG_CLOSE_KEY)GetProcAddress(modBReg, "BRegCloseKey");
BRegSetValueEx = (REG_SET_VALUE_EX)GetProcAddress(modBReg, "BRegSetValueEx");
if (!InitRegEngine || !BRegDeleteKey || !BRegOpenKey || !BRegCloseKey || !BRegSetValueEx) {
FreeLibrary(modBReg);
return FALSE;
}
if (!InitRegEngine()) {
FreeLibrary(modBReg);
return FALSE;
}
return TRUE;
}
示例13: strcpy
/**********************************************************************
* load_display_driver
*
* Special case for loading the display driver: get the name from the config file
*/
static struct graphics_driver *load_display_driver(void)
{
char buffer[MAX_PATH], libname[32], *name, *next;
HMODULE module = 0;
HKEY hkey;
if (display_driver) /* already loaded */
{
display_driver->count++;
return display_driver;
}
strcpy( buffer, "x11" ); /* default value */
/* @@ Wine registry key: HKCU\Software\Wine\Drivers */
if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey ))
{
DWORD type, count = sizeof(buffer);
RegQueryValueExA( hkey, "Graphics", 0, &type, (LPBYTE) buffer, &count );
RegCloseKey( hkey );
}
name = buffer;
while (name)
{
next = strchr( name, ',' );
if (next) *next++ = 0;
snprintf( libname, sizeof(libname), "wine%s.drv", name );
if ((module = LoadLibraryA( libname )) != 0) break;
name = next;
}
if (!(display_driver = create_driver( module )))
{
MESSAGE( "Could not create graphics driver '%s'\n", buffer );
FreeLibrary( module );
ExitProcess(1);
}
display_driver->count++; /* we don't want to free it */
return display_driver;
}
示例14: restore_conf_from_registry
int restore_conf_from_registry(struct a6o_conf * conf) {
int ret = 0;
HKEY hAppKey = NULL;
int res = 0;
struct conf_reg_data data = {0};
if (conf == NULL) {
printf("[-] Error :: invalid parameter\n");
return -1;
}
__try {
if ((res = RegOpenKeyA(HKEY_LOCAL_MACHINE,APP_ROOT_KEY_PATH, &hAppKey)) != ERROR_SUCCESS) {
printf("[-] Error :: RegOpenKeyA failed! :: GLE= %d\n", res);
ret = -2;
__leave;
}
registry_walker(hAppKey,NULL,conf);
//printf("\n\n Armadito_CONF :::\n\n");
// display a6o_conf
//a6o_conf_apply(conf,(a6o_conf_fun_t)display_entry, &data);
}
__finally {
if (hAppKey != NULL) {
RegCloseKey(hAppKey);
hAppKey = NULL;
}
}
return ret;
}
示例15: check_reg_entries
static void check_reg_entries(const char *mrulist, const char**items)
{
char buff[128];
HKEY hKey = NULL;
DWORD type, size, ret;
unsigned int i;
ok(!RegOpenKeyA(HKEY_CURRENT_USER, REG_TEST_FULLKEY, &hKey),
"Couldn't open test key \"%s\"\n", REG_TEST_FULLKEY);
if (!hKey) return;
type = REG_SZ;
size = sizeof(buff);
buff[0] = '\0';
ret = RegQueryValueExA(hKey, "MRUList", NULL, &type, (LPBYTE)buff, &size);
ok(!ret && buff[0], "Checking MRU: got %d from RegQueryValueExW\n", ret);
if(ret || !buff[0]) return;
ok(strcmp(buff, mrulist) == 0, "Checking MRU: Expected list %s, got %s\n",
mrulist, buff);
if(strcmp(buff, mrulist)) return;
for (i = 0; i < strlen(mrulist); i++)
{
char name[2];
name[0] = mrulist[i];
name[1] = '\0';
type = REG_SZ;
size = sizeof(buff);
buff[0] = '\0';
ret = RegQueryValueExA(hKey, name, NULL, &type, (LPBYTE)buff, &size);
ok(!ret && buff[0],
"Checking MRU item %d ('%c'): got %d from RegQueryValueExW\n",
i, mrulist[i], ret);
if(ret || !buff[0]) return;
ok(!strcmp(buff, items[mrulist[i]-'a']),
"Checking MRU item %d ('%c'): expected \"%s\", got \"%s\"\n",
i, mrulist[i], buff, items[mrulist[i] - 'a']);
}
}