home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / activedn / activedn.js < prev    next >
Encoding:
Text File  |  1998-08-22  |  1.1 KB  |  34 lines

  1. // ActiveDNS.js 1.0
  2. // (c) 1998, Activity Software
  3. //
  4. // This is an example of using ActiveDNS within Windows Scripting
  5. // Host.  It also serves to show how to implement ActiveDNS.DLL in
  6. // JScript.
  7. //
  8. // This example uses 127.0.0.1 (loopback device), which should
  9. // demonstrate the functionality of ActiveDNS in almost every scenario.
  10. // 127.0.0.1 should always resolve to localhost, unless the machine
  11. // has been configured otherwise.
  12. //
  13. // Requires: ActiveDNS.DLL, Windows Scripting Host
  14. //
  15. // To execute: CSCRIPT.EXE ACTIVEDNS.JS
  16.  
  17. hostname = "localhost";
  18. address  = "127.0.0.1";
  19.  
  20. DNS=WScript.CreateObject("ActiveDNS.Resolve");
  21.  
  22. // Check for valid address
  23. isvalid = DNS.IsValidNumericAddress(address);
  24.  
  25. // Lookup address by hostname
  26. lookup1 = DNS.Lookup("localhost");
  27.  
  28. // Lookup hostname by address
  29. lookup2 = DNS.ReverseLookup("127.0.0.1");
  30.  
  31. WScript.Echo("Address ["+address+"] "+ (isvalid ? "is" : "is not") + " valid.");
  32. WScript.Echo("Host ["+hostname+"] resolves to address: "+lookup1);
  33. WScript.Echo("Address ["+address+"] resolves to host: "+lookup2);
  34.