HKEY hKey;
DWORD disp ;
DWORD createError = RegCreateKeyEx(
HKEY_LOCAL_MACHINE, // handle of an open key
"Software\\Microsoft\\Windows\\CurrentVersion\\Run", // subkey name
0, // reserved
NULL, // class string
REG_OPTION_NON_VOLATILE, // permanent entry
KEY_READ | KEY_WRITE, // desired security access
NULL, // security attributes (default)
&hKey, // handle for opened key returned
&disp ) ; // created new vs. opened existing
if ( createError == ERROR_SUCCESS )
{
// now can use hKey in other APIs
}
else
{
// createError is an error code which can be looked up
// in WINERROR.H or fed into FormatMessage.
}
//directory of your exe file.
RegSetValueEx(hKey, "hello world",0,REG_SZ,PathToFile,sizeof(PathToFile));
//Close key.
RegCloseKey(hKey);
return 0;
}
but it didn't seem to work .
any idea were it went wrong ?
or any code to create a new key ?
thnk for help in advance