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)

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IE proxy settings live in the registry:  HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet 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\Windows\CurrentVersion\Internet Settings", "ProxyServer")

I think this will solver your purpose.


fab1970Author Commented:
I think i've encountered a version problem:
i'm actually working on a Win98SE machine, i've found that in
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet 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?
PAQed with points refunded (250)

Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.