c# - Auto detect proxy settings if not set on system -


there few questions on here deal finding system defaults , using those. give app "use system defaults" option, work users don't know system behind proxy (and perhaps have less-than-capable staff) therefore might not have proxy settings on system.

how can go auto-detecting proxy (if @ possible)? haven't found post adequately , mdsn isn't helping either...

if understand correctly, check if proxy settings enabled or not, , it's settings. can use following code (vb.net) can converted c# enables / disables proxy , sets proxy value. in general, can use registry achieve it:

   private sub enable_proxy(byval proxyset string)        dim regkeyproxy_enable registrykey        'registry key location        regkeyproxy_enable = registry.currentuser.opensubkey("software\\microsoft\\windows\\currentversion\\internet settings", true)        'change proxy enable value        regkeyproxy_enable.setvalue("proxyenable", 1, registryvaluekind.dword)        'set proxy server value        regkeyproxy_enable.setvalue("proxyserver", proxyset, registryvaluekind.string)    end sub     private sub disable_proxy()        dim regkeyproxy_enable registrykey        regkeyproxy_enable = registry.currentuser.opensubkey("software\\microsoft\\windows\\currentversion\\internet settings", true)        'disable proxy        regkeyproxy_enable.setvalue("proxyenable", 0, registryvaluekind.dword)    end sub 

you can use example , modify needs. please note following key represents proxy setting on windows machine , if remember correctly, applied ie , chrome, recall, firefox uses own settings.

liron


Comments