Function DetectDNSServer() As String Dim Output As String On Error GoTo ErrHandler Set objShell = CreateObject("WScript.Shell") Set objExecObject = objShell.Exec("%comspec% /c ipconfig /all") Output = objExecObject.StdOut.ReadAll() Set objExecObject = Nothing dns = Trim(Replace(Mid(Output, InStr(InStr(1, Output, "DNS Servers"), Output, ":") + 1, 15), Chr(13), "")) DetectDNSServer = dns Exit Function ErrHandler: DetectDNSServer = "127.0.0.1" End FunctionContoh penggunaan:
Private Sub Form_Load() MsgBox DetectDNSServer End SubKegunaannya:
Pada saat kita membuat applikasi server/client (billing Warnet misalnya), pada applikasi clientnya kita tidak harus satu persatu memasukan IP Address servernya.
Semoga Bermanfaat .
No comments:
Post a Comment