
How to set a Proxy Server in IE Component.
In an always greater number of applications, the browser component is very important to visualize web page or display banner that change fastly. So, in most cases is very good idea enabling proxy settings.
You can use InteropServices in this way:
using System.Runtime.InteropServices;
...
//Define external method.
[DllImport("wininet.dll", SetLastError = true)]
private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength);
//Define your method.
private void SetEmugleProxy(string Proxy)
{
const int OPTION_PROXY = 38;
const int OPEN_TYPE_PROXY = 3;
Struct_INTERNET_PROXY ip;
ip.dwAccessType = OPEN_TYPE_PROXY;
ip.proxy = Marshal.StringToHGlobalAnsi(Proxy);
ip.proxyBypass = Marshal.StringToHGlobalAnsi("local");
IntPtr intptrStruct = Marshal.AllocCoTaskMem(Marshal.SizeOf(ip));
// Converting structure to IntPtr.
Marshal.StructureToPtr(ip, intptrStruct, true);
bool iReturn = InternetSetOption(IntPtr.Zero, OPTION_PROXY, intptrStruct, Marshal.SizeOf(ip));
}
---
Enjoy your code! :)
Posted Friday 16 June 2006 - 01:55
Other news about this topic
[C# .NET] Moving WinForm without top-bar. (18/06/2006 - 20:37) read 111 times
[C# .NET] Develop C# Applications under Linux. (17/06/2006 - 16:43) read 79 times
[C# .NET] Play sounds like embedded resources. (17/06/2006 - 16:24) read 108 times
[C# .NET] Set Proxy in IE Component. (16/06/2006 - 01:55) read 99 times
[C# .NET] System.Media VS. PlaySound. (15/06/2006 - 18:36) read 112 times