vb.net - Update Proxy settings from VB application, only works the first time -
i've been trying create simple program change proxy setting, enable/disable proxy. changes setting first time.
i've searched forum , internet, no luck.
i've managed make program work once, when calling toggleproxy() function secound time, first changes registry accordingly, when wininet.dll called refresh setting in internet explorer, old value put registry.
so, when changing proxy , updating ie settings, works fine, when trying change secound time, put backs settings first call.
do need close or clear something? if closing application , starting again, works 1 time again.
is wininet.dll/internetsetoption storing first call somehow?
attaching dll declaration , toggleproxy() function below:
'refresh internet options webbrowsers public declare auto function internetsetoption lib "wininet.dll" (hinternet intptr, dwoption integer, lpbuffer intptr, dwbufferlength integer) boolean public const internet_option_settings_changed = 39 public const internet_option_refresh = 37 'toggle proxy on/off public sub toggleproxy() 'declare temp variable integer dim setvalue integer ' if enableproxy regkey 1, set setvalue 0, else set 1. if proxyregkey = "1" setvalue = "0" else setvalue = "1" end if ' change value in enableproxy regkey value set in setvalue dim autoshell = my.computer.registry.currentuser.opensubkey("software\microsoft\windows\currentversion\internet settings", true) 'set value fo enableproxy according setvalue autoshell.setvalue("proxyenable", setvalue) autoshell.close() messagebox.show("value is:" & setvalue) 're-read proxy regkey. readproxyregkey() 'refresh internet settings internetsetoption(intptr.zero, internet_option_settings_changed, intptr.zero, 0) internetsetoption(intptr.zero, internet_option_refresh, intptr.zero, 0) end sub
appriciate help, seems simple thing, drives me crazy. regards joaqim
Comments
Post a Comment