using System.Runtime.InteropServices; // dll import할때 필요
public struct Struct_INTERNET_PROXY_INFO
{
public int dwAccessType;
public IntPtr proxy; // IP and port
public IntPtr proxyBypass;
};
[DllImport("wininet.dll", SetLastError = true)]
private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength);
private void RefreshIESettings(string strProxy)
{
const int INTERNET_OPTION_PROXY = 38;
const int INTERNET_OPEN_TYPE_PROXY = 3;
Struct_INTERNET_PROXY_INFO struct_IPI;
struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
struct_IPI.proxy = Marshal.StringToHGlobalAnsi(strProxy);
struct_IPI.proxyBypass = Marshal.StringToHGlobalAnsi("local");
IntPtr intptrStruct = Marshal.AllocCoTaskMem(Marshal.SizeOf(struct_IPI));
Marshal.StructureToPtr(struct_IPI, intptrStruct, true);
bool iReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, Marshal.SizeOf(struct_IPI));
}
RefreshIESettings ("프록시ip:port");
webBrowser1.Navigate ("http://naver.com");
'Coding > Etc' 카테고리의 다른 글
C# 디시인사이드 유동닉 댓글달기 (2) | 2015.11.18 |
---|---|
Regex 그룹명 붙이기 (0) | 2015.11.17 |
C# Webbrowser 자바스크립트 에러 disable (0) | 2015.11.13 |
WinhttpRequest (0) | 2015.11.13 |
Regex 활용하여 파싱하기 (0) | 2015.11.12 |