1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| const WCHAR * remote_host = TEXT("remote-host");
const WCHAR * remote_folder = TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\EventCollector\\Subscriptions");
// open the HKLM remote registry
HKEY hkey_remote;
LONG res = RegConnectRegistry(remote_host,
HKEY_LOCAL_MACHINE,
&hkey_remote);
if(res != ERROR_SUCCESS)
{
// something is wrong
WINDOWS("RegConnectRegistry()", res);
return;
}
// open the HKLM remote registry
HKEY hkey_folder;
res = RegOpenKeyEx(hkey_remote,
remote_folder,
0,
KEY_READ,
&hkey_folder);
if(res != ERROR_SUCCESS)
{
// something is wrong
WINDOWS("RegOpenKeyEx()", res);
return;
}
DWORD index = 0;
for(;;)
{
WCHAR Data[256];
DWORD SizeData = sizeof(Data) / sizeof(Data[0]);
long res = RegEnumKeyEx(hkey_folder,
index,
Data,
&SizeData,
NULL,
NULL,
NULL,
NULL);
if(res != ERROR_SUCCESS)
{
// something is wrong, probably the end of the list
WINDOWS("RegEnumKeyEx()", res);
break;
}
// add the key to the list
INFO("Data [%S]", Data);
index++;
}
// close folder
res = RegCloseKey(hkey_folder);
if(res != ERROR_SUCCESS)
{
// something is wrong
WINDOWS("RegCloseKey()", res);
}
res = RegCloseKey(hkey_remote);
if(res != ERROR_SUCCESS)
{
// something is wrong
WINDOWS("RegCloseKey()", res);
} |
Partager