Check Internet Access Server and retrieve date online

Started by hvcrou, September 16, 2011, 05:05:28 AM

Previous topic - Next topic

hvcrou

 Hello

I want a routine that cirar do the following:
1) Check with internet connection
     a) If no connection exists then return nil
     b) If there look for the data server type (times.windows.com, time.nist.gov, etc.) and returns the current date.

I tried to validate the wininet.dll with internet connection but can not import this dll with (vlax-import-type-library) to work beyond that found no information in order to get the value as a return date of a server dates online.

The purpose of this demand and validate date not on the date set in the machine which can be changed by User, but the actual date

Does anyone can help me

thanks

BazzaCAD

Maybe this will help:


Code (autolisp) Select

(defun GetFromWeb (strUrl / webObj stat res errobj)
  ;; Set up variables
  (setq webObj nil stat nil res nil)
  ;; Create a new reference to the WinHttp object
  (setq webObj (vlax-invoke-method (vlax-get-acad-object) 'GetInterfaceObject "WinHttp.WinHttpRequest.5.1"))
  ;; Fetch web page
  (vlax-invoke-method webObj 'Open "GET" strUrl :vlax-false)
  (setq errobj (vl-catch-all-apply 'vlax-invoke-method (list webObj 'Send)))
  (if (null (vl-catch-all-error-p errobj))
    (progn
      (setq stat (vlax-get-property webObj 'Status))
      (if (= stat 200)
        (progn
          (setq res (vlax-get-property webObj 'ResponseText));_ Return the response value
        )
        (princ (strcat "\n!!!Server error: " (vlax-get-property webObj 'StatusText) "!!!"))
      )
    );_ progn
    (princ (strcat "\n!!!Server error:\n" (vl-catch-all-error-message errobj)))
  )
  res 
)
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom