InternetSetOption 的用发: Comment from DChrome Date: 07/16/2003 04:09PM PDT Comment You can modify the registry settings:[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings] [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections]But you should do it only if you are 100% sure of what you are doing. This is not a good thing to mess up with the registry.There's another way - using InternetSetOption function from "wininet.dll". I don't have any ready code to post here. It's a bit complicated so I can only propose the idea. Maybe other experts here can give you a copy and paste solution.Hope this somehow helps. Accepted Answer from Biffo Date: 07/17/2003 08:47AM PDT Accepted Answer InternetSetOption isn't complicated for this task, DChrome. Here is what my nitwit brother-in-law needs to do:'Declare OptionsPrivate Type INTERNET_PROXY_INFO dwAccessType As Long lpszProxy As Long lpszProxyBypass As Long End TypePrivate Const ERROR_INSUFFICIENT_BUFFER = 122 Private Const INTERNET_OPTION_PROXY = 38 Private Const INTERNET_OPEN_TYPE_DIRECT = 1Private 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
给你个例子
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections]
Date: 07/16/2003 04:09PM PDT Comment You can modify the registry settings:[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections]But you should do it only if you are 100% sure of what you are doing. This is not a good thing to mess up with the registry.There's another way - using InternetSetOption function from "wininet.dll".
I don't have any ready code to post here. It's a bit complicated so I can only propose the idea. Maybe other experts here can give you a copy and paste solution.Hope this somehow helps.
Accepted Answer from Biffo
Date: 07/17/2003 08:47AM PDT Accepted Answer InternetSetOption isn't complicated for this task, DChrome. Here is what my nitwit brother-in-law needs to do:'Declare OptionsPrivate Type INTERNET_PROXY_INFO
dwAccessType As Long
lpszProxy As Long
lpszProxyBypass As Long
End TypePrivate Const ERROR_INSUFFICIENT_BUFFER = 122
Private Const INTERNET_OPTION_PROXY = 38
Private Const INTERNET_OPEN_TYPE_DIRECT = 1Private 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'end