Solved

Setting IE Home Pages

Posted on 2002-06-03
7
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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. …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

740 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