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
| #include <stdio.h>
#include <windows.h>
#include <tlhelp32.h>
#include <sstream>
#include <vector>
#include <iostream>
int main()
{
char* cle = "SYSTEM\\ControlSet001\\Enum\\Root";
HKEY hkey;
SECURITY_DESCRIPTOR *descr;
DWORD *SecurityDescriptor;
DWORD retCode2;
DWORD cSubKeys=0, cValues, retCode;
RegOpenKeyEx(HKEY_LOCAL_MACHINE, cle, 0, KEY_READ, &hkey);
retCode2 = RegGetKeySecurity( hkey, SACL_SECURITY_INFORMATION, descr, SecurityDescriptor);
if (retCode2 == ERROR_INSUFFICIENT_BUFFER) printf("Error Buffer\n");
else if (retCode2 == ERROR_SUCCESS) printf ("Ok\n");
system("PAUSE");
RegSetKeySecurity(hkey, SACL_SECURITY_INFORMATION, descr);
//--- Open Legacy ---
//Ouberture de la cl? de registre
retCode = RegOpenKeyEx(HKEY_LOCAL_MACHINE,cle,0,KEY_ALL_ACCESS,&hkey);
if (retCode == ERROR_FILE_NOT_FOUND) {}
else if (retCode == ERROR_ACCESS_DENIED) printf ("Access Denied! Run in administrator mode\n");
else
{
//Lecture de la cl? de registre, r?cup?ration des sous cl?s cSubkey et des valeurs cValues
retCode = RegQueryInfoKey(hkey, NULL,NULL,NULL, &cSubKeys,NULL, NULL, &cValues, NULL, NULL, NULL, NULL);
if (retCode != ERROR_SUCCESS) printf ("Unable to read the registry\n");
}
} |
Partager