Solved

Setting IE Home Pages

Posted on 2002-06-03
7
195 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

914 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

16 Experts available now in Live!

Get 1:1 Help Now