Announcement

Collapse
No announcement yet.

Creative date checking

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creative date checking

    OK I am 98% closest to the greatest evaluation DLL i've ever written, almost foolproof...

    However, I put the date in the secret file, the date the program was last run, and if today's date doesn't match I increment "days", an integer value.


    This is good, but lets say the program is installed and 45 days later they use it again, it should already be timed out, instead it will say it's on day 2.


    So my idea is this:

    Insert the install date in this file.

    Each time the program is run, check the date and check todays date, do the math and figure out hwo many days have elapsed.

    I know someone out there is a whiz at this stuff, and there has GOT to be an easier way than the way I'm conconcting...

    Basically here's my one issue:

    If the program is installed on June 18th for example and times out in 15 days I need ot do the math to figure this out say on July 4th.


    Preciate any input

    Scott

    -------------
    Scott
    mailto:[email protected][email protected]</A>
    MCSE, MCP+Internet
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    Put your installdate (SystemTimeToVariantTime) in your
    'secret file'
    Evaluate (Today minus InstallDate) < EvaluationPeriod in Days


    ------------------
    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se



    [This message has been edited by Fred Oxenby (edited June 12, 2000).]
    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se

    Comment


    • #3
      Scott --

      Add this to your program:

      Code:
      DECLARE FUNCTION CoFileTimeNow LIB "OLE32.DLL" _
                ALIAS "CoFileTimeNow" (qFileTime AS ANY) AS LONG
      Then call it like this:

      Code:
      DIM qTimeNow AS LOCAL QUAD
      CoFileTimeNow qTimeNow
      The qTimeNow value will be an integer that represents the number of 100-nanosecond increments since January 1, 1601. (Amazing but true... It's not a floating point value, it is the exact number of increments, to the accuracy of your system clock.)

      Code:
      %OneDay      =   864000000000&&
      qTimeNow = qTimeNow \ %OneDay
      qTimeNow will now contain the number of days since 1601. You can add and subtract these pseudo-Julian date values to make date math very easy. Calculate today's number, add 15, and voila.

      And the API provides functions (FileTimeToSystemTime and SystemTimeToFileTime) that allow you to convert the "file time" value that is provided by CoFileTimeNow to year/month/day/hour/etc.

      Quads take 8 bytes to store, but they are well worth it!

      -- Eric

      ------------------
      Perfect Sync: Perfect Sync Development Tools
      Email: mailto:[email protected][email protected]</A>



      [This message has been edited by Eric Pearson (edited June 13, 2000).]
      "Not my circus, not my monkeys."

      Comment


      • #4
        This works, so thank you both, You got me thinking on the right track...

        If you see a problem with this please let me know, I tested it repeatedly by changing the date on my PC, and walah!! On day 10 it worked..

        Code:
        Tested with this line:
        If IsPastExpireDate("Jun 01,2000 08:00AM",10) Then MsgBox "Test worked!"
        
        
        '------------------------------------------------------------------------------------------
        'EvalDays is how many days they are allowed To evaluate the software
        'InstallDate will be In this format:
        '           "MMM dd',' yyyy" "hh:mm tt"
        Function IsPastExpireDate(InstallDate As String,EvalDays As Long)Export As Long
        Dim qTimeNow        As Local Quad
        Dim ctdate         As Double
        Dim indate          As Double
        Local st            As SYSTEMTIME
        Local ct            As SYSTEMTIME
        
        'Convert InstallDate to double
        indate = StrToVbDate(InstallDate)
        'Get Current Time
        GetlocalTime ct
        'Convert CurrentDate to double
        SystemTimeToVariantTime ct, ctdate 'Current Time in variant format
        'Compare the two dates and see
        'If it's greater than the allowed evaluation time
        If (ctdate - indate) > EvalDays Then Function = %TRUE
        End Function
        '------------------------------------------------------------------------------------------
        Function uString(ByVal x As String)Export As String
        
          Local y As String
          Local n As Integer
        
          If Len(x) Then
            For n = 1 To Len(x)
              y = y + Mki$(Asc(x, n))
            Next n
          End If
          Function = y
        End Function
        
        '------------------------------------------------------------------------------
        
        Function StrToVbDate(ByVal dt As String) Export As Double
          Local x      As Long
          Local y      As String
          Local vbdate As Double
        
          dt = uString(dt)
          If IsFalse(VarDateFromStr(ByVal StrPtr(dt), 0, 0, vbdate)) Then
            Function = vbdate
          End If
        
        End Function
        ------------------
        Scott
        mailto:[email protected][email protected]</A>
        MCSE, MCP+Internet

        [This message has been edited by Scott Turchin (edited June 13, 2000).]
        Scott Turchin
        MCSE, MCP+I
        http://www.tngbbs.com
        ----------------------
        True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

        Comment

        Working...
        X