;; 
;;=====================================================================================----- 
;; 
;;FUNCTION       kfNSLookup() 
;; 
;;ACTION         Return a name/address pair via NSLookup 
;; 
;;AUTHOR         Glenn Barnas 
;; 
;;VERSION        1.0  - 2007/10/25 
;; 
;;HISTORY        1.0  - 2007/10/25 - Initial Release 
;; 
;;SYNTAX         kfNSLookup(Target) 
;; 
;;PARAMETERS     Target - REQUIRED - String 
;;               - Hostname or IP address to resolve 
;; 
;;REMARKS        Replacement for WSH based functions used in KF apps 
;                This function is designed for use with KixForms GUI apps, where WSH 
;;		 based functions cause a command window to briefly appear. This UDF 
;;		 prevents that from occurring. 
;;               The KF-Classic DLL is required to be registered. 
;; 
;;RETURNS        String - hostname, address, or empty string if not resolved. 
;; 
;;DEPENDENCIES   OS Command NSLookup.exe, KixForms.DLL (classic) 
;; 
;;TESTED WITH    W2K, WXP, W2K3, Vista, X64 
;; 
;;EXAMPLES       If kfNSLookup($Host) 
;;		   $Host ' is in DNS!' ? 
;;		 EndIf 
; 
Function kfNSLookup($Target)
 
  Dim $_oSys				; System KixForms object 
  Dim $_aData				; Array of results 
  Dim $_x, $_Y				; Index vars of results 
  Dim $_Cmd				; command to run 
 
  $_oSys = CreateObject('Kixtart.System')
  $_Cmd   = '%COMSPEC% /c nslookup.exe ' + $Target
  $_aData = Split($_oSys.Shell($_Cmd,0,3), @CRLF)
  $_oSys = 0
 
  $_X = AScan($_aData, 'Name:', 0, , 1)
  $_Y = AScan($_aData, 'Address:', $_X, , 1)
  If $_X = -1 Or $_Y = -1
    $kfNSLookup = ''
    Exit 67
  Else
    $kfNSLookup = Trim(Split($_aData[$_X], ':')[1]) + ',' + Trim(Split($_aData[$_Y], ':')[1])
    Exit 0
  EndIF
 
EndFunction