• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

Setting IE Home Pages

Is there a way to make a C++ program set an Internet Explorer Home Page. I'm using Borland C++ 6 (Personal) Any help (or code) would be appreciated. Thanks!
0
SCSMART
Asked:
SCSMART
  • 3
  • 2
  • 2
1 Solution
 
jhanceCommented:
The IE home page is stored in the Windows registry at:

HKEY_CURRENT_USER\Software\Microsoft\Interner Explorer\Main

and in the value there called "Start Page".

You can modify this using the standard REGISTRY APIs to be whatever you want.
0
 
SCSMARTAuthor Commented:
Ok... now how do I edit the registry, from C++ Builder. In other words how do you modify the Registry API???
0
 
jhanceCommented:
1)Open the key with RegOpenKeyEx():

HKEY hKey;
LONG lResult;
char *lpszNewHomePage = "http://www.experts-exchange.com";

lResult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Interner Explorer\\Main", 0, KEY_ALL_ACCESS, &hKey);
if(lResult != ERROR_SUCCESS){
  // handle error
}

2) Set the value with RegSetValueEx():

lResult = RegSetValueEx(hKey, "StartPage", 0, REG_SZ, lpszNewHomePage, strlen(lpszNewHomePage)+1);
if(lResult != ERROR_SUCCESS){
  // handle error
}

3) Close the registry with RegCloseKey():

RegCloseKey(hKey);
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
DrDelphiCommented:
ScSmart,
  Jhance's is a very valid answer, but it hardly BCB friendly. Try using the TRegistry Object.

For example:
{
  TRegistry *Reg =new TRegistry;
  Reg->OpenKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\Main",false);
  Reg->WriteString("StartPage  "+Whatever the new URL is);
  Reg->CloseKey;
  delete Reg;
 }


Good luck!!
 
0
 
SCSMARTAuthor Commented:
The above answer is correct, but it needs some changes to be useful in Borland C++ 6

1) You need to #include <Registry.hpp>

2) Here's the source code that works...

{
   TRegistry *Reg =new TRegistry;
   Reg->OpenKey("Software\\Microsoft\\Internet Explorer\\Main",false);
   Reg->WriteString("Start Page","http://www.msn.com/");
   Reg->CloseKey();
   delete Reg;
}

Thanks all for your help!
0
 
DrDelphiCommented:
Sorry... I was doing that on the fly. I don't have BCB installed on my system here in the office. <g>

-Dave
0
 
SCSMARTAuthor Commented:
Thanks Dave, I appreciate it. I wasn't doing it to be mean, I just wanted any one in the future who asked to have the exact right answer.

Thanks again,
Carl
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now