none
Visual Studio 2012, Windows Desktop - How do I change browsers?

    Question

  • Just a quick question, I'm currently trying to find out how I can change the internal-browser to the default browser of the host, I'd usually say that Internet Explorer is an option but because of the Login page requires the user to be using a updated browser which would be Firefox, Chrome, Opera, etc it won't work.

    I've tried searching for ways and I hope'd this would be supported and I'd rather not downgrade back to 2010 so I could use a Browser Switcher Extension for it to work. (I'm also a newbie this is my third project)

    Tuesday, September 24, 2013 2:32 AM

Answers

  • Figured it out, its a hidden feature really.

    You need to call "Navigate" instead of the normal "URL" and then put something like this;

    Me.WebSiteBrowser1.Navigate('"YOUR-URL-HERE"', Nothing, Nothing, "User-Agent:This/Is/A/Fake/Agent")

    If you want to do that on every click once you start browsing you're going to need to make a Module and end up importing a .DLL called "urlmon.dll" (It handles most of the URL api) and write a program like this for every session.

    [DllImport("urlmon.dll", CharSet = CharSet.Ansi)]
    private static extern int UrlMkSetSessionOption(int dwOption, string pBuffer, int dwBufferLength, int dwReserved);
    const int URLMON_OPTION_USERAGENT = 0x10000001;
    
    public static void ChangeUserAgent(string Agent)
    {
        UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, Agent, Agent.Length, 0);
    }
    

    • Marked as answer by ImSoto Tuesday, September 24, 2013 6:59 AM
    Tuesday, September 24, 2013 6:59 AM

All replies

  • Figured it out, its a hidden feature really.

    You need to call "Navigate" instead of the normal "URL" and then put something like this;

    Me.WebSiteBrowser1.Navigate('"YOUR-URL-HERE"', Nothing, Nothing, "User-Agent:This/Is/A/Fake/Agent")

    If you want to do that on every click once you start browsing you're going to need to make a Module and end up importing a .DLL called "urlmon.dll" (It handles most of the URL api) and write a program like this for every session.

    [DllImport("urlmon.dll", CharSet = CharSet.Ansi)]
    private static extern int UrlMkSetSessionOption(int dwOption, string pBuffer, int dwBufferLength, int dwReserved);
    const int URLMON_OPTION_USERAGENT = 0x10000001;
    
    public static void ChangeUserAgent(string Agent)
    {
        UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, Agent, Agent.Length, 0);
    }
    

    • Marked as answer by ImSoto Tuesday, September 24, 2013 6:59 AM
    Tuesday, September 24, 2013 6:59 AM
  • Hello,

    Gald to recieve this issue has been resolved. If your issue is related to windows desktop developemnt, Windows Desktop Development forum is a better place for such issue: http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/home?forum=windowsgeneraldevelopmentissues

    Thanks you for you support.

    Best regards,


    Amanda Zhu <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, September 24, 2013 11:01 AM