Is there a way to set a website like google.com as homepage through C++ or C ? How ?
-
4-1 for asking how to write malware. – R.. GitHub STOP HELPING ICE Nov 02 '10 at 04:45
-
google do this as well and it's not a malware. – xRobot Nov 02 '10 at 09:22
-
3they don't do this through C or C++; they do it though the browser. Even so, it's frowned-upon behavior. – MSalters Nov 02 '10 at 09:50
-
MSalters, and the browser is written c/c++... – Tarnay Kálmán Mar 29 '12 at 16:21
-
1Google Chrome Home Page Group Policy http://pdtechguru.wordpress.com/2012/09/25/google-chrome-group-policy – Oct 08 '12 at 20:26
3 Answers
Not sure what your motive is, but I don't think of this as something I want any code on my system to be setting out from under me. It sounds like the kind of thing adware/malware would do to your grandparents (who wouldn't know how to fix it once it's set). Note the negative comments when the question was asked of how to do it from JavaScript:
How can I set default homepage in FF and Chrome via javascript?
It's better to point people at instructions for doing it themselves. Remind with a banner which says "Make us your homepage!", and link to something along these lines:
http://www.makeuseof.com/tag/how-to-change-your-homepage-in-5-browsers/
If not for the aesthetic reasons, there are technical reasons not to try and write code for it. Each browser stores this information in its own place. In IE's case, there appears to be a registry setting:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Start Page
So you'd use calls to the Windows Registry API to query it and set it. But Firefox doesn't save this in the registry, it saves it in something called prefs.js
and you'll be looking for:
user_pref("browser.startup.homepage", .... );
Then there's Opera, Safari, Chrome, etc. All told, better to just give people directions and put them in control of their experience!

- 1
- 1

- 32,904
- 11
- 98
- 167
Yes.
Find the way each browser saves its configuration to disk and edit that (*). It may be a file, or records in a database, or some data in a central registry, or some other scheme --- the browser documentation should tell you.
To open/read/write/save/close a file, the C functions declared in the header <stdio.h>
may be helpful.
(*) for Firefox it's a file named "prefs.ini" in a directory somewhere under the users home path; there may be more than 1 such file if the user has more than 1 profile.

- 106,608
- 13
- 126
- 198
-
If the homepage is set in a central directory (i.e. for Internet Explorer in corporate environments, in Group Policy), the answer will likely be "No". End-users can't edit that setting. – MSalters Nov 02 '10 at 11:38