Author Topic: [C++] Registry Editing  (Read 3722 times)

0 Members and 1 Guest are viewing this topic.

Offline ink

  • Newbie
  • *
  • Posts: 74
    • View Profile
[C++] Registry Editing
« on: February 12, 2006, 02:18:16 pm »
Here's a little app. that can be used to familiarize yourself with registry workings in C++

Code: [Select]

/*/
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;
}


Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [C++] Registry Editing
« Reply #1 on: February 12, 2006, 03:51:21 pm »
There. :P

Offline ink

  • Newbie
  • *
  • Posts: 74
    • View Profile
Re: [C++] Registry Editing
« Reply #2 on: February 12, 2006, 03:59:36 pm »
omg Pwnt! :D