Internet Explorer Proxy Settings

NeXus
NeXus used Ask the Experts™
on
I need to be able to programmatically change the proxy server values in internet explorer, for LAN,
and dialup.

I would prefer no registry hacks thanks! need that uses InternetSetOption ...

I say this only because of risk issues associated with corrupting peoples registries, I have heard some horror stories
about moding these particular settings in the registry...

Anyone got any code to do this using "InternetSetOption" api calls?

Thanks...

P.S. there is an artical here in C++ but I have no idea how to convert it :-)

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q226/4/73.asp&NoWebContent=1
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
Ok whacked it up some, points wise, I feel this is a tricky / undocumented area
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Author

Commented:

>_agi_ suggested http://www.vbip.com/wininet/wininet_connection_02.asp 
...  nothing here about proxies or here: http://www.vbip.com/wininet

>harris_c said: http://www-tcsn.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20680780.html
... saw this yesterday,  but this doesnt compile under VB6! plus I need to set the option permanently.

500 points up for grabs here boys n gurls! come on down!!!

how about some code?

NeXus

Commented:
The first link is not a total zero, there is some general overview of the process, but nothing as to the SPECIFIC one.

Author

Commented:
thanks, sure _agj_

but unfortunately nothing worth any points...

Commented:
Try (reuse this code):

Option Explicit

Private Type INTERNET_PROXY_INFO
    dwAccessType    As Long
    lpszProxy       As String
    lpszProxyBypass As String
End Type

Private Const ERROR_INSUFFICIENT_BUFFER = 122
Private Const INTERNET_OPTION_PROXY = 38
Private Const INTERNET_OPEN_TYPE_DIRECT = 1
Private Const INTERNET_OPEN_TYPE_PROXY = 3

Private Declare Function InternetSetOption Lib "wininet.dll" Alias "InternetSetOptionA" (ByVal hInternet As Long, ByVal dwOption As Long, ByRef lpBuffer As Any, ByVal dwBufferLength As Long) As Long

'On form add a command1 button


Private Sub Command1_Click()
   
    Dim iRet As Long
    Dim ProxyInfo As INTERNET_PROXY_INFO
   

        ProxyInfo.dwAccessType = INTERNET_OPEN_TYPE_PROXY
        ProxyInfo.lpszProxy = ("http=127.0.0.1:8080")
        ProxyInfo.lpszProxyBypass = "<local>"

   
    iRet = InternetSetOption(0&, INTERNET_OPTION_PROXY, ProxyInfo, LenB(ProxyInfo))
    '
    If iRet <> 0 Then
      MsgBox "Now Using Proxy Service.", vbInformation
        Else
      MsgBox "Error in Setting IE Proxy Service.", vbInformation
       End If
   
End Sub

Commented:
The difference is in some declarations added n changed.

Author

Commented:
Sorry that didnt work,

That may have changed the proxy settings temporarily, but I need them to visually change (and persist) in the internet explorer settings.

Thanks for the effort
:-)

Commented:
ooppps that is c++ code but you should get the idea
I think after you did the change to proxy setting should broadcast a message to the system to tell that it was... Changed.

Author

Commented:
Not answered: get a refund thanks
Commented:
PAQed, with points refunded (500)

CetusMOD
Community Support Moderator

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial