fab1970
asked on
How to get Proxy settings from the default browser, and use them
I'm building a telnet application, and i want to support proxy.
The question is: How to get the proxy settings from the default browser?
(i say "default browser" 'cause i always use IE, i don't know if others have differents way to use a proxy)
The question is: How to get the proxy settings from the default browser?
(i say "default browser" 'cause i always use IE, i don't know if others have differents way to use a proxy)
IE proxy settings live in the registry: HKEY_CURRENT_USER\Software \Microsoft \Windows\C urrentVers ion\Intern et Settings
Put following in a module
*-----------------
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegOpenKeyA Lib "advapi32.dll" (ByVal hKey As Long, ByVal SubKey As String, Result As Long) As Long
Public Declare Function RegQueryValueExA Lib "advapi32.dll" (ByVal hKey As Long, ByVal KVName As String, ByVal Rvd As Long, Tpe As Long, Dta As Any, cbDta As Long) As Long
Public Function ReadRegistry(hKey As Long, KeyPath As String, SValue As String, Optional Default As String) As String
On Error Resume Next
Dim Buffr As String
RegOpenKeyA hKey, KeyPath, hCurKey
RegQueryValueExA hCurKey, SValue, 0&, lngValueType, ByVal 0&, lngDataBufferSize
Buffr = String(lngDataBufferSize, " ")
RegQueryValueExA hCurKey, SValue, 0&, 0&, ByVal Buffr, lngDataBufferSize
ZPos = InStr(Buffr, Chr$(0))
ReadRegistry = Left$(Buffr, ZPos - 1)
RegCloseKey hCurKey 'close Key !!
End Function
*-----------------
Then a textbox and put following in form load event
*------------------------
Text1.Text = ReadRegistry(&H80000001, "Software\Microsoft\Window s\CurrentV ersion\Int ernet Settings", "ProxyServer")
*------------------------
I think this will solver your purpose.
Ashish
*-----------------
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegOpenKeyA Lib "advapi32.dll" (ByVal hKey As Long, ByVal SubKey As String, Result As Long) As Long
Public Declare Function RegQueryValueExA Lib "advapi32.dll" (ByVal hKey As Long, ByVal KVName As String, ByVal Rvd As Long, Tpe As Long, Dta As Any, cbDta As Long) As Long
Public Function ReadRegistry(hKey As Long, KeyPath As String, SValue As String, Optional Default As String) As String
On Error Resume Next
Dim Buffr As String
RegOpenKeyA hKey, KeyPath, hCurKey
RegQueryValueExA hCurKey, SValue, 0&, lngValueType, ByVal 0&, lngDataBufferSize
Buffr = String(lngDataBufferSize, " ")
RegQueryValueExA hCurKey, SValue, 0&, 0&, ByVal Buffr, lngDataBufferSize
ZPos = InStr(Buffr, Chr$(0))
ReadRegistry = Left$(Buffr, ZPos - 1)
RegCloseKey hCurKey 'close Key !!
End Function
*-----------------
Then a textbox and put following in form load event
*------------------------
Text1.Text = ReadRegistry(&H80000001, "Software\Microsoft\Window
*------------------------
I think this will solver your purpose.
Ashish
ASKER
mmmhh
I think i've encountered a version problem:
i'm actually working on a Win98SE machine, i've found that in
"HKEY_CURRENT_USER\Softwar e\Microsof t\Windows\ CurrentVer sion\Inter net Settings"
i have a subkey called "Connections" containing two Binary value, "DefaultConnectionSettings " and "SavedLegacySettings".
Have each Windows version a different place to store these data?
More: how to "extract" settings from these values?
I think i've encountered a version problem:
i'm actually working on a Win98SE machine, i've found that in
"HKEY_CURRENT_USER\Softwar
i have a subkey called "Connections" containing two Binary value, "DefaultConnectionSettings
Have each Windows version a different place to store these data?
More: how to "extract" settings from these values?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.