Announcement

Collapse
No announcement yet.

Question...

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

  • Question...

    How's that for generic?

    SystemTimeToVariantTime, remember this one?


    This works on my system, and with my newly found friend in Australia (Say Hi Wayne) he GPF's.
    We swapped OLEAUT32.DLL'S just to test, same thing....
    He uses a BYCOPY ctdate below and it works, but I don't nad it works.

    Our declares are both:
    DECLARE FUNCTION SystemTimeToVariantTime LIB "OLEAUT32.DLL" ALIAS "SystemTimeToVariantTime" (lpSystemTime AS SYSTEMTIME, vbtime AS DOUBLE) AS LONG

    The code:
    Code:
    '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,ExpireDate As String,EvalDays As Long)Export As Long
    'Dim qTimeNow        As Local Quad
    Dim ctdate          As Double
    Dim indate          As Double
    Dim edate           As Double
    Local ct            As SYSTEMTIME
    Local et            As SYSTEMTIME
    
    '-------------------
    'Get Current Time
    GetlocalTime ct
    'Convert CurrentDate to double
    
    GPF HERE on his PC, not mine:
    SystemTimeToVariantTime ct, ctdate 'Current Time in variant format
    '-------------------
    If Len(ExpireDate) Then
        'Convert ExpirationDate to double
        edate = StrToVbDate(ExpireDate)
        'if todays date is bigger than the expiration date then we expired
        If ctdate > edate Then Function = %TRUE
    Else
        'Convert InstallDate to double
        indate = StrToVbDate(InstallDate)
        'Compare the two dates and see If it's greater than the allowed evaluation time
        If (ctdate - indate) > EvalDays Then Function = %TRUE
    End If
    End Function
    ------------------
    Scott
    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
    FIXED!!!
    The solution - as Fred Oxenby discovered on October 07, 1999, the "BYVAL" in the win32api.inc declaration was wrong and should have been "BYREF"
    SystemTimeToVariantTime can then be called normally, eg:
    SystemTimeToVariantTime ct, ctdate

    Many thanks Fred!

    Code:
    #COMPILE EXE "timetest.exe"
    TYPE SYSTEMTIME
      wYear AS INTEGER
      wMonth AS INTEGER
      wDayOfWeek AS INTEGER
      wDay AS INTEGER
      wHour AS INTEGER
      wMinute AS INTEGER
      wSecond AS INTEGER
      wMilliseconds AS INTEGER
    END TYPE
    DECLARE SUB GetLocalTime LIB "KERNEL32.DLL" ALIAS "GetLocalTime" (lpSystemTime AS SYSTEMTIME)
    DECLARE FUNCTION SystemTimeToVariantTime LIB "OLEAUT32.DLL" ALIAS "SystemTimeToVariantTime" (lpSystemTime AS SYSTEMTIME, BYREF vbtime AS DOUBLE) AS LONG
    
    Function PBMAIN() As Long
    Dim ctdate          As Double
    Local ct            As SYSTEMTIME
    'Get Current Time
    GetLocalTime ct
    Msgbox "Current year = " & Format$(ct.wYear)
    'Convert CurrentDate to double
    SystemTimeToVariantTime ct, ctdate 'Current Time in variant format, GPF OCCURS HERE!
    Msgbox "ctdate=" & Str$(ctdate)
    End Function



    [This message has been edited by Wayne Diamond (edited February 18, 2001).]
    -

    Comment


    • #3
      check your win32api.inc date!
      VbTime has to be a pointer to a double as the api will return a value in this variable.

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

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

      Comment

      Working...
      X