Checking the date but not from the local machine

mcdhappy80

Registered User.
Local time
Today, 16:35
Joined
Jun 22, 2009
Messages
347
Can I somehow connect with VBA from Access to time.windows.com in order to check which is current date, because as You know users can change the date on their local machine and thus fool the software?
Or maybe use some ActiveX control or something?
Any ideas on this?

Thank You
 
what if the user has no access to the internet? does that render them unable to use your software at all?
 
what if the user has no access to the internet? does that render them unable to use your software at all?
Well, yes, unless You have some other idea from where I can read the current system date besides calendar in the lower right corner of windows OS, because if they change date in calendar, lets say a year from now in the past, they still have one year to use my program, so by my opinion it's better for them to install internet service in their company that for me to give them my software freely, unless, as I say, someone can help me overcome this problem some other way :)

Many things crossed my mind on how to solve this, but each one of them involved using internet connection and reading a date from some site, importing it and then doing the math in VBA.

Thank You
 
How about storing the "seen" dates/times in your program...
Then if the time goes "backwards" fail the date check...
 
If the software is installed on a network you can use the following code.

Code:
Option Explicit

Private Declare Function NetRemoteTOD Lib "Netapi32.dll" (tServer As Any, pBuffer As Long) As Long

Private Declare Function NetApiBufferFree Lib "Netapi32.dll" (ByVal lpBuffer As Long) As Long

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

Private Type TIME_OF_DAY_INFO
    tod_elapsedt As Long
    tod_msecs As Long
    tod_hours As Long
    tod_mins As Long
    tod_secs As Long
    tod_hunds As Long
    tod_timezone As Long
    tod_tinterval As Long
    tod_day As Long
    tod_month As Long
    tod_year As Long
    tod_weekday As Long
End Type

Public Function getServerDateTime(ByVal strServer As String) As String

    'This function will get the system date & time of the target machine it is passed.
    'If the server cannot be reached we return null

    Dim result As Date
    Dim lRet As Long
    Dim tod As TIME_OF_DAY_INFO
    Dim lpbuff As Long
    Dim tServer() As Byte

    tServer = strServer & vbNullChar
    lRet = NetRemoteTOD(tServer(0), lpbuff)

    If lRet = 0 Then
        CopyMemory tod, ByVal lpbuff, Len(tod)
        NetApiBufferFree lpbuff
        result = DateSerial(tod.tod_year, tod.tod_month, tod.tod_day) + _
            TimeSerial(tod.tod_hours, tod.tod_mins - tod.tod_timezone, tod.tod_secs)
        getServerDateTime = result
    Else
        getServerDateTime = ""
    End If
End Function

Then on the on load of the application you can call

Code:
getServerDateTime("<<NameOfYourServerHere>>")

You can then compare the date on the local pamchine with the date form the server.

David
 
How about storing the "seen" dates/times in your program...
Then if the time goes "backwards" fail the date check...

What do You mean by "seen" dates, maybe the last date application was started?
If yes, then that system isn't foolproof, the better way is to check the date somewhere else.
Where would You store the "seen" dates, table, property?

If the software is installed on a network you can use the following code.

The software will be installed on one workstation but there is server on that network definitively.

Code:
Option Explicit

Private Declare Function NetRemoteTOD Lib "Netapi32.dll" (tServer As Any, pBuffer As Long) As Long

Private Declare Function NetApiBufferFree Lib "Netapi32.dll" (ByVal lpBuffer As Long) As Long

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

Private Type TIME_OF_DAY_INFO
    tod_elapsedt As Long
    tod_msecs As Long
    tod_hours As Long
    tod_mins As Long
    tod_secs As Long
    tod_hunds As Long
    tod_timezone As Long
    tod_tinterval As Long
    tod_day As Long
    tod_month As Long
    tod_year As Long
    tod_weekday As Long
End Type

Public Function getServerDateTime(ByVal strServer As String) As String

    'This function will get the system date & time of the target machine it is passed.
    'If the server cannot be reached we return null

    Dim result As Date
    Dim lRet As Long
    Dim tod As TIME_OF_DAY_INFO
    Dim lpbuff As Long
    Dim tServer() As Byte

    tServer = strServer & vbNullChar
    lRet = NetRemoteTOD(tServer(0), lpbuff)

    If lRet = 0 Then
        CopyMemory tod, ByVal lpbuff, Len(tod)
        NetApiBufferFree lpbuff
        result = DateSerial(tod.tod_year, tod.tod_month, tod.tod_day) + _
            TimeSerial(tod.tod_hours, tod.tod_mins - tod.tod_timezone, tod.tod_secs)
        getServerDateTime = result
    Else
        getServerDateTime = ""
    End If
End Function
Then on the on load of the application you can call

Code:
getServerDateTime("<<NameOfYourServerHere>>")
You can then compare the date on the local pamchine with the date form the server.

David
Can the <<NameOfYourServerHere>> be the adress of the server that is on internet and I connect on it through the web?

Thank you guys :)
 
Seen: Yes, last opened date...

This you can store in many places, text file in the temp folder, properties, tables...
Even if you check servers, there is always a way around these things... Why even bother ?

Or check the C:\Temp for the most recent / latest file compared to the system date?
Other locations?
 

Users who are viewing this thread

Back
Top Bottom