我运行SYSTEM服务但无法读取 HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Run。
但可以使用当前用户运行。
HKEY hKey;
DWORD dwType=0;
TCHAR szValueName[MAXBYTE]={0};
TCHAR szValueKey[MAXBYTE]={0};
DWORD dwBufferSize=MAXBYTE;
DWORD dwKeySize=MAXBYTE;
if(RegOpenKey(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",&hKey)!=ERROR_SUCCESS)
{
return;
}
int i=0;
while(TRUE)
{
if(RegEnumValue(hKey,i,szValueName,&dwBufferSize,NULL,&dwType,(LPBYTE)szValueKey,&dwKeySize)==ERROR_NO_MORE_ITEMS)
{
break;
}
printf("%s\n",szValueName);
i++;
dwBufferSize = MAXBYTE;
dwKeySize = MAXBYTE;
ZeroMemory(szValueName,MAXBYTE);
ZeroMemory(szValueKey,MAXBYTE);
}