Jump to content

Search the Community

Showing results for tags 'dnsqueryconfig'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Hi folks, Last morning I needed to know programmatically which were my DNS(s) for the current connection, and I searched for an API which fitted my needs... I just tried dnsqueryconfig, which shows the DNS(s) used, if you have manually selected them in the past. The API is little tricky (or maybe I'm little rusty), so I decided to write a small UDF function to avoid a waste of time in the future... here you are. ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_DnsQueryConfig ; Description ...: Retrieves the currently used DNS servers, if they were selected by user ; Syntax.........: _WinAPI_DnsQueryConfig() ; Return values .: On success it returns an array with the list of currently used DNS servers ; ; On failure it returns 0 and sets @error to non zero (these values are useful only for debugging reasons): ; |1 - DllCall error ; |2 - Generic error, DNS could be generated automatically ; Author ........: j0kky ; Modified ......: 1.0.0 14/11/2018 ; Link ..........: https://docs.microsoft.com/en-us/windows/desktop/api/windns/nf-windns-dnsqueryconfig ; =============================================================================================================================== Func _WinAPI_DnsQueryConfig() Local Const $DnsConfigDnsServerList = 6 Local $aRet = DllCall("Dnsapi.dll", "LONG", "DnsQueryConfig", "int", $DnsConfigDnsServerList, "dword", 0, "ptr", Null, "ptr", 0, "ptr", Null, "dword*", 0) If @error Then Return SetError(1, 0, 0) if $aRet[6] <= 4 Then Return SetError(2, 0, 0) Local $tagBuffer = "" For $i = 1 To ($aRet[6] / 4) $tagBuffer &= "dword;" Next Local $tBuffer = DllStructCreate($tagBuffer) $aRet = DllCall("Dnsapi.dll", "LONG", "DnsQueryConfig", "int", $DnsConfigDnsServerList, "dword", 0, "ptr", Null, "ptr", 0, "ptr", DllStructGetPtr($tBuffer), "dword*", $aRet[6]) Local $aDNS[($aRet[6] / 4) - 1] For $i = 2 to (UBound($aDNS) + 1) $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "dword", DllStructGetData($tBuffer, $i)) if @error Then Return SetError(1, 0, 0) $aDNS[$i - 2] = $aRet[0] Next Return SetError(0, 0, $aDNS) EndFunc
×
×
  • Create New...