convert to c#

  • Thread starter Thread starter Zürcher See
  • Start date Start date
Z

Zürcher See

Who can tell me how to convert the InternetSetOption in c#?



#include "Wininet.h"

#pragma comment(lib, "Wininet.lib")


static BOOL SetRegisterInfo(HKEY Key, LPCTSTR SubKey, LPCTSTR find, DWORD
set)

{


.....

}

void OnDisableWWW()

{

SetRegisterInfo(HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
"ProxyEnable", (DWORD)0);

SetRegisterInfo(HKEY_LOCAL_MACHINE,
"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
"ProxyEnable", (DWORD)0);
BOOL bProxy = 0;

bProxy = InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL,
0);

bProxy = InternetSetOption(NULL, INTERNET_OPTION_REFRESH, NULL, 0);

}



void OnEnableWWW()

{

SetRegisterInfo(HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
"ProxyEnable", (DWORD)1);

SetRegisterInfo(HKEY_LOCAL_MACHINE,
"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
"ProxyEnable", (DWORD)1);

BOOL bProxy = 0;

bProxy = InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL,
0);

bProxy = InternetSetOption(NULL, INTERNET_OPTION_REFRESH, NULL, 0);

}
 
Maybe

Boolean InternetSetOption(IntPtr, UInt32, IntPtr, UInt32);

Haven't tested it though.
 
Is System.Net.GlobalProxySelection what you want? The System.Net
namespace contains everything you want to do Internet stuff.

The Select method sets the proxy that all HttpWebRequest instances use.
 
I can't use the HttpWebRequest, I have to use internet explorer
(AxInterop.SHDocVw.dll), it has been "asked" from our customer.
 
Ok, but why don't you just DllImport InternetSetOption() from wininet.dll?

[DllImport("wininet.dll")]
InternetSetOption(IntPtr, UInt32, IntPtr, UInt32);
 
Ops, now I have found it, befor I looked for it but I haven't found it,
perhaps a type error

thanks

Antenna said:
Ok, but why don't you just DllImport InternetSetOption() from wininet.dll?

[DllImport("wininet.dll")]
InternetSetOption(IntPtr, UInt32, IntPtr, UInt32);

Zürcher See said:
I can't use the HttpWebRequest, I have to use internet explorer
(AxInterop.SHDocVw.dll), it has been "asked" from our customer.
 
Back
Top