Solved

Setting IE Home Pages

Posted on 2002-06-03
7
220 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

717 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