Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] having some problems with Registry

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sat Jul 12, 2008 2:46 am    Post subject: [C++] having some problems with Registry Reply with quote

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 Confused

_________________
Stylo
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Sat Jul 12, 2008 3:07 am    Post subject: Reply with quote

Check out the info at the bottom of this page:
http://msdn.microsoft.com/en-us/library/ms724921(VS.85).aspx

Other Registry functions:
http://msdn.microsoft.com/en-us/library/ms724875(VS.85).aspx

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sat Jul 12, 2008 4:21 am    Post subject: Reply with quote

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
View user's profile Send private message
jackyyll
Expert Cheater
Reputation: 0

Joined: 28 Jan 2008
Posts: 143
Location: here

PostPosted: Sat Jul 12, 2008 10:31 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address MSN Messenger
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sat Jul 12, 2008 11:12 am    Post subject: Reply with quote

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
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sat Jul 12, 2008 1:01 pm    Post subject: Reply with quote

thx lurc for the function works perfectly :]
_________________
Stylo
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites