开发者

how to use InternetSetOption

How to use InternetSetOption? I go throught the details here. It also says something related with OptionFlags. Anybody know how to use the second parameter to the function ?. The information can be found here. Its little bit confusing, for example

INTERNET_OPTION_CONNECTED_STATE: 50:

Sets or retrieves an unsigned long integer value that contains the connected state. This is used by InternetQueryOption and InternetSetOption.

What does 开发者_开发问答it mean if I pass a 50 as the second parameter?


What are you actually trying to accomplish?

Generally speaking, you shouldn't be trying to set the INTERNET_OPTION_CONNECTED_STATE, as this is set automatically by the system and allows you to collect information about the status of the system's network connection.

You generally use the InternetSetOption API thusly:

// Announce to the world that we've changed the proxy
InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY_SETTINGS_CHANGED, IntPtr.Zero, 0);

// ISSUE: We're using ANSI here because calling functions marshal in ANSI. MSDN suggests that W-versions might not work in older IE versions.
[DllImport("wininet.dll", SetLastError=true, CharSet=CharSet.Ansi)]  
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool InternetSetOption(IntPtr hInternet, int Option, [In] IntPtr buffer, Int32 BufferLength);

But if you're doing something more complicated, like setting the proxy using INTERNET_PER_CONN_OPTION, you can use a different signature to more easily pass in the required structure.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜