Results 1 to 9 of 9

Thread: Refresh Internet Settings

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    227

    Refresh Internet Settings

    Alright everyone, this is a huge problem I've been having for a while. How exactly would I go about refreshing the internet settings so that a webbrowser will check the registry again for the IP to use? Instead of just using the IP that's there when the browser is first instantiated. Here's what I'm looking for that someone else directed me to, however it's in C#. I'm sure there's a method like this in VB.NET, however I have no idea what it may be.

    Here's the link: http://social.msdn.microsoft.com/for...A-5FBE7A46B61A


    Thanks!!!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Refresh Internet Settings

    If you have a C# solution then the VB solution will be the same, just using Vb syntax instead of C#. All the types and members will be the same, as will the structure of the code. Syntax is the only difference. There are numerous tools and online converters available to convert between C# and VB and vice versa.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    227

    Re: Refresh Internet Settings

    I understand that, however in VB10 it will not let me import WinInet, which is needed for this. Is there a way around that?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Refresh Internet Settings

    Quote Originally Posted by arcticfang View Post
    I understand that, however in VB10 it will not let me import WinInet, which is needed for this. Is there a way around that?
    That's simply not true. The DllImportAttribute works EXACTLY the same in ALL versions of VB.NET and ALL versions of C# and ALL versions of EVERY other .NET language too (Delphi, C++/CLR, etc). If your OS has a wininet.dll library then you can use DllImport to invoke functions from it no matter. I just had a look in my own System32 folder on a Win7 x64 system and wininet.dll was there, so that would indicate that it's part of all Windows versions. If it's not working for you then it's because you're not doing it correctly. Have you read the MSDN documentation for the DllImportAttribute class to see how to use it correctly in VB.NET to import an unmanaged function? You could always post your code here and tell us what actually happens when you try to use it sowe could help you fix it, but you should definitely check the doco first.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    227

    Re: Refresh Internet Settings

    Alright, here's what I'm using.

    To import the DLL:

    Code:
    Module WinInet
        <DllImport("wininet.dll", CharSet:=CharSet.Unicode)> Function InternetSetOption(ByVal hInternet, ByVal dwOption, ByVal lpBuffer, ByVal dwBufferLength)
        End Function
    
    End Module
    To use the function that I imported:

    Code:
            settingsreturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0)
            refreshreturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0)
    And it's giving me the error "MarshalDirectiveException was unhandled". What am I doing wrong?

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    227

    Re: Refresh Internet Settings

    Can anyone help me with this? I've personally never used anything like this, and my previous post is what I've gotten out of the documentation.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Refresh Internet Settings

    I've never used that function but the first thing you should do is turn Option Strict On. That will force you to specify a type for each parameter and the function itself, which you should ALWAYS do. Nothing should ever not have a defined type.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    227

    Re: Refresh Internet Settings

    Alright, I've done that. How do I specify a type for the function? Like what would I put for InternetSetOption As __?

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    227

    Re: Refresh Internet Settings

    Nevermind, I've gotten everything figured out. I just need help on one more thing.. thanks a ton for your help!!!!!!

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