In order to complete a simple registry removal program, since I am Win7 64-bit OS, write the following code to recursively delete the registry key values, the program code is as follows:
#include <tchar.h> #include <afx.h> #define Key_wow64_64key 256long deletesubkeytree (HKEY HKEY, LPCTSTR Lpsubkey) {LONG lResult; HKEY Hsubkey;dword dwindex, CBName; Char szsubkey[512]; FILETIME ft; LResult = RegOpenKeyEx (hkey,lpsubkey,0,key_all_access | Key_wow64_64key,&hsubkey); if (lResult! = ERROR_SUCCESS) {RegCloseKey (hsubkey); return 0;} dwindex = 0;cbname = sizeof (Szsubkey)/sizeof (szsubkey[0]); while (error_success = = (LResult = RegEnumKeyEx (Hsubkey), Dwindex, Szsubkey, &cbname, NULL, NULL, NULL, &FT))) {Deletesubkeytree (Hsubkey, Szsubkey);} RegCloseKey (hsubkey); lResult = Regdeletekey (HKey, Lpsubkey); return lResult;} int main () {LPCTSTR deletetext = _t ("software\\bentley\\licensing"); Deletesubkeytree (Hkey_local_machine,deletetext);:: MessageBox (NULL, _t ("cracked successfully! ")," ", MB_OK); return 0;}
found that the key value exists, in the call RegQueryValueEx always query failure, returned 0, always thought to be the issue of permissions, to upgrade it to debug or not, the network also has a friend said to create. mainfest file elevation, later on the MSDN Web also found the relevant instructions. But it still failed. Put this program into XP and Win7 32 can be read out of the value of the normal. So I think it would be a 64-bit OS problem? Finally, Microsoft's latest MSDN online found the answer. It turns out that operating in the 64-bit OS registry must be aware of setting a value. First in the file header definition:
#define KEY_WOW64_64KEY 256//compatible with 64-bit host
Then add the parameters of the RegOpenKeyEx
key_all_access| key_wow64_64key, //All access rights