News:

Who uses forums anymore?

Main Menu

[C++] Registry Editing

Started by ink, February 12, 2006, 02:18:16 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ink

Here's a little app. that can be used to familiarize yourself with registry workings in C++



/*/
Changes IE Homepage via Registry
/*/

#include <Windows.h>
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int main()
{
HKEY hKey;
unsigned char newHomepage[75]; // variable to hold new homepage value

cout << "Enter homepage: "; // user input
cin >> newHomepage;

LONG lnReg = RegOpenKeyEx( // opens the main registry key for internet explorer

HKEY_CURRENT_USER,
"SOFTWARE\\Microsoft\\Internet Explorer\\Main",
0L, KEY_WRITE,
&hKey
);


if( ERROR_SUCCESS == lnReg )
{
lnReg = RegSetValueEx(hKey, // sets new homepage value
LPCTSTR( "Start Page" ),
0,     
REG_SZ,   
newHomepage,
strlen((char*)newHomepage) );
if( ERROR_SUCCESS == lnReg )
cout << "Homepage successfully set to: " << newHomepage << endl;
else
cout << "Failed to set new homepage!" << endl;
}
return 0;
}


Sidoh


ink