Having problem saving key in windows registry. here is the code
On the save I am getting error 1314:ERROR_PRIVILEGE_NOT_HELDCode:#include "stdafx.h" #include <stdlib.h> #include <stdio.h> #include <windows.h> #include <tchar.h> #include <iostream> #include <string.h> int saveKey(HKEY tree, const char *folder){ long lRval; HKEY hKey; // Open location lRval = RegOpenKeyEx( tree, folder, 0, KEY_READ, &hKey ); if (lRval != ERROR_SUCCESS) { printf("open failed: %ld",lRval); return 0; } lRval = RegSaveKeyEx(hKey,"envBack",NULL,REG_LATEST_FORMAT); if (lRval != ERROR_SUCCESS) { printf("save failed: %ld", lRval); return 0; } else return 1; } // This is the entry point for this application int _tmain(void) { //BACKUP REGISTRY KEY: HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet -> Control -> Session Manager -> Environment if (saveKey(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment")) printf("BACKUP OF REGISTRY KEY: HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet -> Control -> Session Manager -> Environment successful"); else printf("BACKUP OF REGISTRY KEY: HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet -> Control -> Session Manager -> Environment failed"); return 0; }
A required privilege is not held by the client.
But not sure what that means. I am administrator on my machine.
Any help?



LinkBack URL
About LinkBacks


