Solved

Setting IE Home Pages

Posted on 2002-06-03
7
189 Views
Last Modified: 2010-05-18
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
Comment
Question by:SCSMART
  • 3
  • 2
  • 2
7 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 7051883
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
 

Author Comment

by:SCSMART
ID: 7051907
Ok... now how do I edit the registry, from C++ Builder. In other words how do you modify the Registry API???
0
 
LVL 32

Expert Comment

by:jhance
ID: 7051922
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 6

Accepted Solution

by:
DrDelphi earned 95 total points
ID: 7052239
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
 

Author Comment

by:SCSMART
ID: 7052643
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
 
LVL 6

Expert Comment

by:DrDelphi
ID: 7053714
Sorry... I was doing that on the fly. I don't have BCB installed on my system here in the office. <g>

-Dave
0
 

Author Comment

by:SCSMART
ID: 7054137
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now