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!!!
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.
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?
Re: Refresh Internet Settings
Quote:
Originally Posted by
arcticfang
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.
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?
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.
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.
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 __?
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!!!!!!