如何读取注册表RUN项里面有几个键值!

来源:百度知道 编辑:UC知道 时间:2024/05/15 02:15:27
RT..
用批处理,或者别的方法..

仅供参考:

#include <windows.h>

const char *RarKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\WinRAR.exe";
const char *vKey = "Path";
char vValue[MAX_PATH]={0};

BOOL GetRarKey(void)
{
HKEY hKey;
DWORD nSize=MAX_PATH;
LONG ret;

ret = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
RarKey,
0,
KEY_ALL_ACCESS,
&hKey );

if (ret != ERROR_SUCCESS)
{
MessageBox(NULL,"failed in openning Key!","ERROR",MB_OK);
return false;
}

ret=RegQueryValueEx(hKey,
vKey,
NULL,
NULL,
(LPBYTE)vValue,
&nSize);
RegCloseKey(hKey);

if (ret!=ERROR_SUCCESS)
{
MessageBox(NULL,"failed in querying key!","ERROR",MB_OK);
return false;
}
MessageBox(NULL,vValue,vKey,MB_OK);
return true;
}