Results 1 to 4 of 4

Thread: [2008] Change User Homepage

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    159

    [2008] Change User Homepage

    I haven't found exactly what I am looking for so I am hoping someone can clue me in here. I want to add a textbox to my form where the user can input a new homepage and click set button and update their homepage. The code on the forums only works for IE. Is there an easy way to detect their browser and set the homepage correctly depending on their default webbrowser?

    chris

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2008] Change User Homepage

    Hey,

    Kleinma has got some code in the codebank that figures out what the default browser the user has and you can find that here.

    Assuming that you can figure out what browser they are using, you should then be able to do an application specific creation of the favourite.

    Hope that helps!!

    Gary

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    159

    Re: [2008] Change User Homepage

    Yeah, and I've used that code in the past but I'm fairly new and don't know all what he's doing in there so that will be a problem.

    chris

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2008] Change User Homepage

    What exactly about the codebank submission that you don't understand?

    From a quick glance at the code, he is using a call to an API function, which works out the executable files associated with a particular file type, in this case an htm file. By doing this, he can work out the default browser. The executable file is then returned in the following code:

    Code:
                'CALL THE API TO FIND THE EXE ASSOCIATED WITH HTM FILES
                RetVal = FindExecutable(FileName, vbNullString, BrowserExec)
                BrowserExec = BrowserExec.Trim
    In the code that Kleinma posted, he is then simply passing this executable into a Process.Start which then fires up the default broswer, and he does this here:

    Code:
                'IF WE GET ONE, LAUNCH THE URL IN THE NEW INSTANCE OF THE BROWSER
                If RetVal <= 32 Or BrowserExec = String.Empty Then
                    MessageBox.Show("Could not find a valid web browser")
                Else
                    Process.Start(BrowserExec, strUrl)
                End If
    So rather than do the Process.Start line, you would inspect the BrowserExec variable. If this contains the string firefox, then you would do the firefox specific favourite saving, if the string contained iexplore, then you would do the internet explorer favourite saving. You could extend this to include any browsers that you wanted to support in your application.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width