How to get Proxy settings from the default browser, and use them

Posted on 2004-10-31
Last Modified: 2011-09-20
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)

Question by:fab1970
    LVL 7

    Expert Comment

    IE proxy settings live in the registry:  HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
    LVL 2

    Expert Comment

    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.



    Author Comment

    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?

    Accepted Solution

    PAQed with points refunded (250)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    856 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now