Need some vb6 code to set the homepage in firefox 2.0

I need to on a command1_click set the home page on firefox to "www.myhomepage.com" the code need to be in visual basic 6 .
newprogramAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shanmuga SundaramDirector of Software EngineeringCommented:
usually the homepage can be set by writing in registry

HKEY_CLASSES_ROOT\http\shell\open\command.

There are plenty of codes available in vbaccelerator.com, a1vbcode.com,programmersheaven.com to handle registry. Please check and use it to accompolish the task
0
newprogramAuthor Commented:
I thought firefox don't save the homepage to the registry
0
newprogramAuthor Commented:
will that set all webbrowsers ie,firefox , ect ?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

advfinanceCommented:
See the following line in prefs.js file.

user_pref("browser.startup.homepage", "http://www.google.co.uk/ig");

located in the application data folder, for example:

C:\Documents and Settings\username\Application Data\Mozilla\Firefox\Profiles\random.default\prefs.js

Warning at the top of the file that edits made while firefox is running will be overwritten when it exits.
0
PaulHewsCommented:
Complete code.  Requires reference to Microsoft VBScript Regular Expressions 5.5
Private Sub SetFirefoxHomepage(URL As String)
    
    Dim strPath As String, strProfile As String
    Dim strContent As String, strReplace As String
    Dim regex As RegExp
    
    
    
    strPath = "C:" & Environ("HOMEPATH")
    strPath = strPath & "\Application Data\Mozilla\Firefox\Profiles\"
    strProfile = Dir(strPath & "*.default", vbDirectory)
    If Len(strProfile) Then
        Debug.Print strProfile
        strPath = strPath & strProfile & "\prefs.js"
        
        strContent = fGetFileContents(strPath)
        Set regex = New RegExp
        regex.Pattern = "user_pref\(""browser.startup.homepage"",\s""(.*)""\);"
        strReplace = "user_pref(""browser.startup.homepage"", """ & URL & """);"
        Debug.Print strReplace
        
        strContent = regex.Replace(strContent, strReplace)
        sPutStringToFile strContent, strPath
        
    End If
    
    
 
End Sub
Public Function fGetFileContents(strPath As String) As String
    Dim hFile As Integer
    Dim strFileContent As String
    
    
    If Len(Dir(strPath)) = 0 Then Exit Function
    On Error GoTo errGetFile
    hFile = FreeFile
    Open strPath For Binary As #hFile
    strFileContent = Space(LOF(hFile))
    Get #hFile, , strFileContent
    Close #hFile
    fGetFileContents = strFileContent
    Exit Function
errGetFile:
    Close
    MsgBox Err.Description, vbCritical, "GetFileContents"
    
End Function
 
Public Sub sPutStringToFile(strContent As String, strPath As String)
    Dim hFile As Integer
    
    'If file exists delete it.
    On Error Resume Next
    Kill strPath
    On Error GoTo errPutString
    
    'Write file
    hFile = FreeFile
    Open strPath For Binary As #hFile
    Put #hFile, , strContent
    Close #hFile
    
    Exit Sub
errPutString:
 
    Close
    MsgBox Err.Description, vbCritical, "PutStringToFile"
 
End Sub

Open in new window

0
newprogramAuthor Commented:
this is the only thing in the file for me "# Mozilla User Preferences

/* Do not edit this file.
 *
 * If you make changes to this file while the browser is running,
 * the changes will be overwritten when the browser exits.
 *
 * To make a manual change to preferences, you can visit the URL about:config
 * For more information, see http://www.mozilla.org/unix/customizing.html#prefs
 */
0
newprogramAuthor Commented:
how would you call it ?
SetFirefoxHomepage "http://yahoo.com"
0
PaulHewsCommented:
If you don't have any preferences set (from the empty preference file above) then it probably won't work.  You would have to set up some defaults.  You could write them from VB or copy a file programmatically into the profile folder.
0
PaulHewsCommented:
>how would you call it ?
SetFirefoxHomepage "http://yahoo.com"<

Yep.  When there are defaults already in the file.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.