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


C++ RegEnumKey函数代码示例

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


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

示例1: ProcessDir

/*
 * Determine if there is an acceptable JRE in the registry directory top_key.
 * Upon locating the "best" one, return a fully qualified path to it.
 * "Best" is defined as the most advanced JRE meeting the constraints
 * contained in the manifest_info. If no JRE in this directory meets the
 * constraints, return NULL.
 *
 * It doesn't matter if we get an error reading the registry, or we just
 * don't find anything interesting in the directory.  We just return NULL
 * in either case.
 */
static char *
ProcessDir(manifest_info* info, HKEY top_key) {
    DWORD   index = 0;
    HKEY    ver_key;
    char    name[MAXNAMELEN];
    int     len;
    char    *best = NULL;

    /*
     * Enumerate "<top_key>/SOFTWARE/JavaSoft/Java Runtime Environment"
     * searching for the best available version.
     */
    while (RegEnumKey(top_key, index, name, MAXNAMELEN) == ERROR_SUCCESS) {
        index++;
        if (JLI_AcceptableRelease(name, info->jre_version))
            if ((best == NULL) || (JLI_ExactVersionId(name, best) > 0)) {
                if (best != NULL)
                    JLI_MemFree(best);
                best = JLI_StringDup(name);
            }
    }

    /*
     * Extract "JavaHome" from the "best" registry directory and return
     * that path.  If no appropriate version was located, or there is an
     * error in extracting the "JavaHome" string, return null.
     */
    if (best == NULL)
        return (NULL);
    else {
        if (RegOpenKeyEx(top_key, best, 0, KEY_READ, &ver_key)
          != ERROR_SUCCESS) {
            JLI_MemFree(best);
            if (ver_key != NULL)
                RegCloseKey(ver_key);
            return (NULL);
        }
        JLI_MemFree(best);
        len = MAXNAMELEN;
        if (RegQueryValueEx(ver_key, "JavaHome", NULL, NULL, (LPBYTE)name, &len)
          != ERROR_SUCCESS) {
            if (ver_key != NULL)
                RegCloseKey(ver_key);
            return (NULL);
        }
        if (ver_key != NULL)
            RegCloseKey(ver_key);
        return (JLI_StringDup(name));
    }
}
开发者ID:Gustfh,项目名称:jdk8u-dev-jdk,代码行数:61,代码来源:java_md.c

示例2: _recursively_delete_all_sub_keys

static LONG _recursively_delete_all_sub_keys(HKEY key_handle, LPCTSTR key_name)
{
    HKEY child_key_handle = NULL;
    LONG ret = 0;
    LPTSTR temporary_key_name = NULL;

    ret = RegOpenKeyEx(key_handle, key_name, NULL, KEY_ALL_ACCESS, &child_key_handle);

    if (ret != ERROR_SUCCESS) {
        return(ret);
    }

    try {
        temporary_key_name = new TCHAR[ MAX_PATH ];
    }
    catch(...) {
        temporary_key_name = NULL;
    }

    if (temporary_key_name == NULL) {
        return(ERROR_NOT_ENOUGH_MEMORY);
    }

    ret = RegEnumKey(child_key_handle, 0, temporary_key_name, MAX_PATH);
    while(ret == ERROR_SUCCESS) {
        _recursively_delete_all_sub_keys(child_key_handle, temporary_key_name);

        ret = RegEnumKey(child_key_handle, 0, temporary_key_name, MAX_PATH);
    }

    delete [] temporary_key_name;
    temporary_key_name = NULL;
    RegCloseKey(child_key_handle);
    ret = RegDeleteKey(key_handle, key_name);

    return(ret);
}
开发者ID:BackupTheBerlios,项目名称:texlive,代码行数:37,代码来源:Registry.cpp

示例3: RegistryGather

/* Gather list of keys */
int RegistryGather(BOOL wEvents)
{
	DWORD size;
	HKEY registry_handle;
	char name[EVENTLOG_NAME_SZ];
	int errnum;
	int index;

	/* Open location for enumerating key information */
	if (RegOpenKey(HKEY_LOCAL_MACHINE, RegistryEventlogKeyPath, &registry_handle)) {
		Log(LOG_ERROR|LOG_SYS, "Cannot initialize access to registry: \"%s\"", RegistryEventlogKeyPath);
		return 1;
	}

	/* Process keys until end of list */
	index = 0;
	while (1) {

		/* Get next key */
		size = sizeof(name);
		errnum = RegEnumKey(registry_handle, index, name, size);

		/* Stop if last item */
		if (errnum == ERROR_NO_MORE_ITEMS)
			break;

		/* Check for error */
		if (errnum) {
			Log(LOG_ERROR|LOG_SYS, "Cannot enumerate registry key: \"%s\"", RegistryEventlogKeyPath);
			break;
		}

		/* Create new eventlog */
		if (wEvents) {
			if (WinEventlogCreate(name))
				break;
		} else {
			if (EventlogCreate(name))
				break;
		}
		/* Advance index number */
		index++;
	}
	/* Close registry */
	RegCloseKey(registry_handle);

	/* Return status */
	return errnum != ERROR_NO_MORE_ITEMS;
}
开发者ID:bpladna,项目名称:eventlog-to-cef,代码行数:50,代码来源:registry.c

示例4: disable_reduceping

void disable_reduceping() {
    HKEY rootkey;
    
    /* open the root key */
    if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, ROOT_KEY, 0, KEY_READ, &rootkey) != ERROR_SUCCESS) {
        error("ReducePing can't find any network interface keys in the registry and can not continue.");
        exit(1);
    }
    
    /* get number of sub keys (these are the TCP interfaces, assuming a regular windows registry) */
    DWORD numsubkeys;
    if (RegQueryInfoKey(rootkey, NULL, NULL, NULL, &numsubkeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) {
        error("ReducePing has encountered an error during querying the amount of sub keys and can not continue.");
        RegCloseKey(rootkey);
        exit(1);
    }
    
    /* iterate over sub keys */
    long i;
    for (i = 0; i < numsubkeys; i++) {
        char subkey[256 + sizeof(ROOT_KEY)];
        
        strncpy(subkey, ROOT_KEY, strlen(ROOT_KEY));
        
        if (RegEnumKey(rootkey, i, subkey + strlen(ROOT_KEY), sizeof(subkey)) != ERROR_SUCCESS) {
            error("ReducePing has encountered an error during enumerating registry keys, attempting to continue.");
            continue;
        }
        
        /* open sub key for writing (in our case deletion) */
        HKEY tcpkey;
        if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, subkey, 0, KEY_WRITE, &tcpkey) != ERROR_SUCCESS) {
            error("ReducePing can't write to the registry, make sure that your Windows account has Administrator rights.");
            RegCloseKey(rootkey);
            return;
        }
        
        /* delete the TcpAckFrequency value */
        if (RegDeleteValue(tcpkey, "TcpAckFrequency") != ERROR_SUCCESS) {
            error("ReducePing encountered an error while deleting the TcpAckFrequency registry value, attempting to continue.");
            RegCloseKey(tcpkey);
            continue;
        }
        
        RegCloseKey(tcpkey);
    }
    
    RegCloseKey(rootkey);
}
开发者ID:orlp,项目名称:ReducePing,代码行数:49,代码来源:reduceping.c

示例5: Subsets_EnumSubsets

BOOL Subsets_EnumSubsets (LPTSTR pszCell, size_t iIndex, LPTSTR pszSubset)
{
   BOOL rc = FALSE;

   HKEY hk;
   if ((hk = OpenSubsetsKey (pszCell, FALSE)) != NULL)
      {
      if (RegEnumKey (hk, (DWORD)iIndex, pszSubset, cchNAME) == 0)
         rc = TRUE;

      RegCloseKey (hk);
      }

   return rc;
}
开发者ID:maxendpoint,项目名称:openafs_cvs,代码行数:15,代码来源:subset.cpp

示例6: WNInstall_RegDeleteKeys

int WNInstall_RegDeleteKeys(HKEY thiskey, const char * lpSubKey)
{
	HKEY key;
	int retval=RegOpenKey(thiskey,lpSubKey,&key);
	if (retval==ERROR_SUCCESS)
	{
		char buffer[1024];
		while (RegEnumKey(key,0,buffer,1024)==ERROR_SUCCESS)
            if ((retval=WNInstall_RegDeleteKeys(key,buffer)) != ERROR_SUCCESS) break;

		RegCloseKey(key);
		retval=RegDeleteKey(thiskey,lpSubKey);
	}
	return retval;
}
开发者ID:jdkoftinoff,项目名称:if2kv2,代码行数:15,代码来源:wninstall.cpp

示例7: strlen

PCHAR *GetSubkeyNames( PCHAR MainKeyName, PCHAR Append ) {
    int i = 0;
    DWORD Error;
    HKEY MainKey;
    PCHAR *Out, OutKeyName;
    DWORD CharTotal = 0, AppendLen = 1 + strlen(Append);
    DWORD MaxSubKeyLen = 0, MaxSubKeys = 0;

    Error = RegOpenKey( HKEY_LOCAL_MACHINE, MainKeyName, &MainKey );

    if( Error ) return NULL;

    Error = RegQueryInfoKey
        ( MainKey,
          NULL, NULL, NULL,
          &MaxSubKeys, &MaxSubKeyLen,
          NULL, NULL, NULL, NULL, NULL, NULL );

    MaxSubKeyLen++;
    DH_DbgPrint(MID_TRACE,("MaxSubKeys: %d, MaxSubKeyLen %d\n",
                           MaxSubKeys, MaxSubKeyLen));

    CharTotal = (sizeof(PCHAR) + MaxSubKeyLen + AppendLen) * (MaxSubKeys + 1);

    DH_DbgPrint(MID_TRACE,("AppendLen: %d, CharTotal: %d\n",
                           AppendLen, CharTotal));

    Out = (CHAR**) malloc( CharTotal );
    OutKeyName = ((PCHAR)&Out[MaxSubKeys+1]);

    if( !Out ) { RegCloseKey( MainKey ); return NULL; }

    i = 0;
    do {
        Out[i] = OutKeyName;
        Error = RegEnumKey( MainKey, i, OutKeyName, MaxSubKeyLen );
        if( !Error ) {
            strcat( OutKeyName, Append );
            DH_DbgPrint(MID_TRACE,("[%d]: %s\n", i, OutKeyName));
            OutKeyName += strlen(OutKeyName) + 1;
            i++;
        } else Out[i] = 0;
    } while( Error == ERROR_SUCCESS );

    RegCloseKey( MainKey );

    return Out;
}
开发者ID:oneminot,项目名称:reactos,代码行数:48,代码来源:adapter.c

示例8: SIGAR_JNI

JNIEXPORT jstring SIGAR_JNI(win32_RegistryKey_RegEnumKey)
(JNIEnv *env, jclass, jlong hkey, jint index)
{
    jstring strResult;
    TCHAR   szBuffer[MAX_PATH + 1];
    DWORD len = sizeof(szBuffer) / sizeof(TCHAR);

    if(RegEnumKey((HKEY)hkey, index, szBuffer, 
                  len) == ERROR_SUCCESS)
        strResult = env->NewString((const jchar *)szBuffer, 
                                   lstrlen(szBuffer));
    else
        strResult = NULL;

    return strResult;
}
开发者ID:kroepke,项目名称:sigar,代码行数:16,代码来源:registrykey.cpp

示例9: RegCopyClassName

/* RegCopyClassName() - Returns the ASCII class id from the listbox.
 */
BOOL FAR RegCopyClassName(HWND hwndList, LPSTR lpstrClassName) {
    BOOL    fSuccess = FALSE;
    DWORD   dwSize = 0L;
    HKEY    hkeyTemp;
    char    szClass[KEYNAMESIZE];
    char    szExec[KEYNAMESIZE];
    char    szKey[KEYNAMESIZE];
    char    szName[KEYNAMESIZE];
    int     i;
    int     iWhich;

    iWhich = (int)SendMessage(hwndList, LB_GETCURSEL, 0, 0L);
    SendMessage(hwndList, LB_GETTEXT, iWhich, (DWORD)(LPSTR)szKey);

    RegOpenKey(HKEY_CLASSES_ROOT,NULL,&hkeyRoot);
    for (i = 0; !fSuccess && !RegEnumKey(HKEY_CLASSES_ROOT, i++, szClass, KEYNAMESIZE); )
        if (*szClass != '.') {          /* Not default extension... */

            /* See if this class really refers to a server */
            dwSize = 0;
            hkeyTemp = NULL;
            lstrcpy(szExec, szClass);
            lstrcat(szExec, "\\protocol\\StdFileEditing\\server");

            if (!RegOpenKey(HKEY_CLASSES_ROOT, szExec, &hkeyTemp)) {
                /* ... get the class name string */
                dwSize = KEYNAMESIZE;
                if (!RegQueryValue(HKEY_CLASSES_ROOT, szClass, szName, &dwSize)
                    && !lstrcmp(szName, szKey))
                    fSuccess = TRUE;

                RegCloseKey(hkeyTemp);
            }
        }

    if (fSuccess)
        lstrcpy(lpstrClassName, szClass);

    if (hkeyRoot)
    {
        RegCloseKey(hkeyRoot);
        hkeyRoot = NULL;
    }

    return fSuccess;
}
开发者ID:chunhualiu,项目名称:OpenNT,代码行数:48,代码来源:objreg.c

示例10: FindDeviceInRegistry

//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
BOOL FindDeviceInRegistry(LPSTR szStartKey, LPSTR szSearchStr)
{
	HKEY TopKey, CurKey; 
	DWORD dwTypeCode, dwSizeOfDataBuffer;
	char szValueBuffer[MAX_PATH];
	char szNewKeyName[MAX_PATH];
	long i;
	
	dwTypeCode = REG_SZ;
//	szDest[0] = '\0';
	
	if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szStartKey, 0, 
		KEY_ALL_ACCESS, &TopKey) == ERROR_SUCCESS)
	{
		for (i=0; 
			RegEnumKey(TopKey, i, szValueBuffer, MAX_PATH) == ERROR_SUCCESS;
			i++)
		{
			sprintf(szNewKeyName, "%s\\%s", szStartKey, szValueBuffer);
			if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szNewKeyName, 0, 
				KEY_ALL_ACCESS, &CurKey) == ERROR_SUCCESS)
			{
				dwSizeOfDataBuffer = MAX_PATH;
				memset(szValueBuffer, 0, MAX_PATH);
				RegQueryValueEx(CurKey, "DeviceDesc", NULL, &dwTypeCode, 
					(LPBYTE) szValueBuffer, &dwSizeOfDataBuffer);
				if (strstr(szValueBuffer, szSearchStr))
				{
					RegCloseKey(CurKey);					
					return TRUE;
				}
				else
				{
					if (FindDeviceInRegistry(szNewKeyName, szSearchStr))
					{
						RegCloseKey(CurKey);
						return TRUE;
					}
				}
				RegCloseKey(CurKey);
			}
		}
	}
	return FALSE;
}
开发者ID:BygoneWorlds,项目名称:anet,代码行数:47,代码来源:detect.c

示例11: Scan

void Scan(HKEY root, LPWSTR subkey, HWND hwnd) {
	HKEY key;
	int err = RegOpenKeyEx(root, subkey, 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &key);

	if (err != 0) {
		return;
	}

	int index = 0;
	char* name[10240];
	while ((err = RegEnumKey(key, index++, (LPWSTR)name, 10240)) != ERROR_NO_MORE_ITEMS) {
		if (lstrlen(subkey) == 0)
			Scan(root, (LPWSTR)name, hwnd);
		else {
			char path[10240];
			swprintf((LPWSTR)path, L"%s\\%s", subkey, name);
			Scan(root, (LPWSTR)path, hwnd);
		}
	}

	index = 0;
	int type, size = 1024;
	char data[1024];
	int namesize = 1024;
	while ((err = RegEnumValue(key, index++, (LPWSTR)name, (LPDWORD)&namesize, 0, (LPDWORD)&type, (LPBYTE)data, (LPDWORD)&size)) == 0) {
		if (type == REG_SZ) {
			char str[10240];
			swprintf((LPWSTR)str, L"%s\\%s = %s\n", subkey, name, data);
			if (lstrlen((LPWSTR)data) > 2) 
				if (wcsstr((LPWSTR)data, L"C:")) {
					HANDLE f = CreateFile((LPWSTR)data, GENERIC_READ, FILE_SHARE_READ,NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL);
					if (f == INVALID_HANDLE_VALUE) {
						WIN32_FIND_DATA d;
						//found wrong key value - send to list
						if (FindFirstFile((LPWSTR)data, &d) == INVALID_HANDLE_VALUE)
							SendMessage(hList, LB_ADDSTRING, 0, (LPARAM)str);
					} else
						CloseHandle(f);
				}
		}
		namesize = size = 1024;
	}
	RegCloseKey(key);
}
开发者ID:keipa,项目名称:bsuir-labs,代码行数:44,代码来源:Lab8.cpp

示例12: RegOpenKeyEx

void CRegisterExport::EnumerateKey(HKEY hKey,CString strKey, FILE *fp,CString cstrFullPath)
{
	TCHAR strCurString[1024];
	long lResult;
	DWORD dwCurIndex = 0;
	HKEY hCurKey;
	CString strCurKey;
	CString strSubKey = strKey;
	CString strFullKey = cstrFullPath;

	//// first open the root key to get the handle...
	lResult = RegOpenKeyEx(hKey, strKey, 0, KEY_ENUMERATE_SUB_KEYS, &hCurKey);
	if( lResult != ERROR_SUCCESS )
		return;

	do
	{
		lResult = RegEnumKey(hCurKey, dwCurIndex, strCurString , sizeof(strCurString));

		if((lResult == ERROR_NO_MORE_ITEMS) || (lResult == ERROR_INVALID_HANDLE))
		{
			break;
		}
		else
		{
			strCurKey.Format(_T("%s"),strCurString);
			if(strCurKey.IsEmpty())
				strFullKey = cstrFullPath;
			else
			{
				strFullKey = cstrFullPath + _T("\\") + strCurKey;
				strSubKey  = strKey + _T("\\") + strCurString;
			}
			EnumerateValues(hKey, strSubKey , fp, strFullKey);
			if(IsSubKey(hKey , strSubKey))
			{				
				EnumerateKey(hKey , strSubKey , fp, strFullKey);
			}
			dwCurIndex++;
		}

	}while(TRUE);
	RegCloseKey(hCurKey);
}
开发者ID:vizcount,项目名称:work,代码行数:44,代码来源:RegisterExport.cpp

示例13: IsSubKey

BOOL CRegisterExport::IsSubKey(HKEY hKey,LPCTSTR lpSubKey)
{
	if(IsExist(hKey,lpSubKey))
	{
		HKEY phkResult;
		if( ERROR_SUCCESS == RegOpenKeyEx(hKey,lpSubKey,0,
			KEY_READ,&phkResult))
		{
			TCHAR sz[MAX_PATH];
			if( ERROR_SUCCESS == RegEnumKey(phkResult, 0, sz, MAX_PATH))
			{
				RegCloseKey(phkResult);
				return TRUE;
			}
			RegCloseKey(phkResult);
		}
	}
	return FALSE;
}
开发者ID:vizcount,项目名称:work,代码行数:19,代码来源:RegisterExport.cpp

示例14: RegOpenKeyEx

	void MainWindow::SearchRegistry(HKEY root, LPWSTR subkey, ListView *listView)
	{
		HKEY key;
		int resultCode = RegOpenKeyEx(root, subkey, 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &key);
		if (resultCode != 0)
			return;

		int index = 0;
		WCHAR name[10 * MAX_STR];
		while (RegEnumKey(key, index++, name, 10240) != ERROR_NO_MORE_ITEMS && !SearchAgain && ThreadNeeded)
		{
			if (lstrlen(subkey) == 0)
				SearchRegistry(root, name, listView);
			else
			{
				WCHAR path[10 * MAX_STR];
				swprintf(path, 10 * MAX_STR, L"%s\\%s", subkey, name);
				SearchRegistry(root, path, listView);
			}
		}

		index = 0;
		BYTE data[20 * MAX_STR];
		DWORD namesize = 10 * MAX_STR, type, size = 20 * MAX_STR;
		while (RegEnumValue(key, index++, name, &namesize, NULL, &type, data, &size) != ERROR_NO_MORE_ITEMS
			&& !SearchAgain && ThreadNeeded)
		{
			if (type == REG_SZ)
			{
				LPWSTR path = LPWSTR(data);
				WCHAR tmp[MAX_STR];
				lstrcpy(tmp, L":\\");
				if (lstrlen(path) != 0 && tmp[0] == path[1] && tmp[1] == path[2] && PathFileExists(path) == FALSE)
				{
					int newRow = listView->AddItem(subkey, -1, 0);
					listView->AddItem(name, newRow, 1);
					listView->AddItem(path, newRow, 2);
				}
			}
			namesize = size = 1024;
		}
		RegCloseKey(key);
	}
开发者ID:kinpa200296,项目名称:SP_labs,代码行数:43,代码来源:MainWindow.cpp

示例15: while

BOOL CReg::GetKey(HKEY hKey, LPCTSTR pKey, DWORD dwSubkeys, BOOL bMerge, LPCTSTR pKeyname )
{_STTEX();
	if ( !bMerge ) Destroy();

	HKEY hOKey = NULL;

	// Open the key
	if ( RegOpenKeyEx(	hKey, pKey,0, 
		KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, 
		&hOKey ) != ERROR_SUCCESS )
		return FALSE;

	DWORD i = 0;
	char name[ 1024 ];
	char keyname[ 1024 ];

	// For each 
	while( RegEnumKey( hOKey, i++, name, sizeof( name ) ) == ERROR_SUCCESS )
	{
		// Build the key name
		if ( pKeyname != NULL ) CWinFile::BuildPath( keyname, pKeyname, name );
		else CRKey::GetKeyName( hKey, pKey, keyname );

		// Add key
		LPREGKEY prf = (LPREGKEY)AddKey( keyname );
		if ( prf != NULL )
		{
			// Get key
			prf->key->SetName( keyname );
			prf->key->GetKey( hOKey, name );

			// Recurse for subkeys
			if ( dwSubkeys ) GetKey( hOKey, name, dwSubkeys - 1, TRUE, keyname );

		} // end if		

	} // end while

	RegCloseKey( hOKey );

	return TRUE;
}
开发者ID:aminsyed,项目名称:rulib,代码行数:42,代码来源:Reg.cpp


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