 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Sat Jul 12, 2008 2:46 am Post subject: [C++] having some problems with Registry |
|
|
well i'm trying to add a value key to registry
so first of all i added a key to HKCU:
| Code: |
HKEY hKey;
DWORD dwDisp = 0;
LPDWORD lpdwDisp = &dwDisp;
RegCreateKeyEx(HKEY_CURRENT_USER,L"Software\\Testkey",NULL,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hKey,lpdwDisp);
RegCloseKey(hKey);
|
so far all good
but when i'm trying to add a value to this key
| Code: |
RegSetKeyValue(HKEY_CURRENT_USER,L"Software\\Testkey",L"stringVal",REG_SZ,(LPCVOID)"c:\\program files",MAX_PATH);
|
suddenly when i run the EXE i get error message that says that the entry point for the procedure RegSetKeyValue couldn't be located in advapi32.dll
_________________
Stylo |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Sat Jul 12, 2008 4:21 am Post subject: |
|
|
i already watched that pages that's where i learn this functions
i dont know why it's giving me this error message
_________________
Stylo |
|
| Back to top |
|
 |
jackyyll Expert Cheater
Reputation: 0
Joined: 28 Jan 2008 Posts: 143 Location: here
|
Posted: Sat Jul 12, 2008 10:31 am Post subject: |
|
|
From http://msdn.microsoft.com/en-us/library/ms724921.aspx
| Code: |
LONG WINAPI RegSetKeyValue(
__in HKEY hKey,
__in_opt LPCTSTR lpSubKey,
__in_opt LPCTSTR lpValueName,
__in DWORD dwType,
__in_opt LPCVOID lpData,
__in DWORD cbData
);
hKey [in]
A handle to an open registry key. The key must have been opened with the KEY_SET_VALUE access right. For more information, see Registry Key Security and Access Rights.
This handle is returned by the RegCreateKeyEx, RegCreateKeyTransacted, RegOpenKeyEx, or RegOpenKeyTransacted function. It can also be one of the following predefined keys:
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
|
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sat Jul 12, 2008 11:12 am Post subject: |
|
|
RegSetValueEx's first parameter is the HKEY you defined above.
I made a function to open and then set a value to that entry. (This is the string version)
| Code: | BOOL CreateKey( LPTSTR lpKey, LPTSTR lpName, LPTSTR lpsText )
{
HKEY hKey;
if ( RegOpenKeyEx( HKEY_CURRENT_USER, lpKey, 0, KEY_ALL_ACCESS, &hKey ) == ERROR_SUCCESS )
{
if ( RegSetValueEx( hKey, lpName, 0, REG_SZ, (CONST BYTE*)lpsText, MAX_PATH ) == ERROR_SUCCESS )
{
RegCloseKey( hKey );
return TRUE;
}
}
RegCloseKey( hKey );
return FALSE;
} |
Just as an example, You can replace RegOpenKeyEx with RegCreateKeyEx.
_________________
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Sat Jul 12, 2008 1:01 pm Post subject: |
|
|
thx lurc for the function works perfectly :]
_________________
Stylo |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|