944,074 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 23981
  • C++ RSS
Nov 25th, 2007
0

Editing Windows Registry

Expand Post »
I want to create a C++ Program to edit the Windows Registry. For example to change the home page of internet explorer. But I don't know how to read or edit the help.

I am doing this program just for my own self and is not a part of homework.
Similar Threads
Reputation Points: 31
Solved Threads: 3
Junior Poster
krnekhelesh is offline Offline
127 posts
since Jul 2007
Nov 25th, 2007
0

Re: Editing Windows Registry

I got the following source from the internet... but I don't know how to manipulate it for my convience

C++ Syntax (Toggle Plain Text)
  1. #include <windows.h>
  2. #include <iostream>
  3.  
  4. int main () {
  5.  
  6. HKEY hKey; // Declare a key to store the result
  7. DWORD buffersize = 1024; // Declare the size of the data buffer
  8. char* lpData = new char[buffersize];// Declare the buffer
  9.  
  10. /* Open the Registry Key at the location
  11. HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
  12. with read only access
  13. */
  14.  
  15. RegOpenKeyEx (HKEY_CURRENT_USER,
  16. "Software\\Microsoft\\Internet Explorer\\Main",NULL,KEY_READ,&hKey);
  17.  
  18. // Query the registry value
  19. RegQueryValueEx(hKey,"Start Page",NULL,NULL,(LPBYTE) lpData,&buffersize);
  20.  
  21. // Print out the registry value
  22. std::cout << "Registry Key Open: memory location=" << hKey << "\n";
  23. std::cout << "Your Internet Start Page is " << lpData << "\n\n";
  24.  
  25. // Close the Registry Key
  26. RegCloseKey (hKey);
  27.  
  28. // Pause the system so there is time to read what is going on
  29. system("Pause");
  30.  
  31. delete lpData;
  32. }
Last edited by krnekhelesh; Nov 25th, 2007 at 5:34 am. Reason: code error
Reputation Points: 31
Solved Threads: 3
Junior Poster
krnekhelesh is offline Offline
127 posts
since Jul 2007
Nov 25th, 2007
0

Re: Editing Windows Registry

but the thing is it edits reads only strings... I want to read a value which has binary values.... How do I do that?
Reputation Points: 31
Solved Threads: 3
Junior Poster
krnekhelesh is offline Offline
127 posts
since Jul 2007
Nov 25th, 2007
1

Re: Editing Windows Registry

you still use RegQueryValueEx.
C++ Syntax (Toggle Plain Text)
  1. LONG WINAPI RegQueryValueEx( HKEY hKey, LPCTSTR lpValueName,
  2. LPDWORD lpReserved,
  3. LPDWORD lpType, // will be set to the type of data
  4. // (eg. REG_BINARY if value was binary)
  5. LPBYTE lpData, LPDWORD lpcbData );
see http://msdn2.microsoft.com/en-us/library/ms724884.aspx for the registry value types.
Last edited by vijayan121; Nov 25th, 2007 at 6:33 am.
Reputation Points: 1159
Solved Threads: 285
Posting Virtuoso
vijayan121 is offline Offline
1,606 posts
since Dec 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: c2440 error??
Next Thread in C++ Forum Timeline: Help with creating a class





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC