Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Question about _Date_Time_GetSystemTimeAsFileTime


  • Please log in to reply
15 replies to this topic

#1 benners

benners

    Wayfarer

  • Active Members
  • Pip
  • 99 posts

Posted 10 August 2008 - 11:38 PM

Is the function supposed to return the current date in the UTC format?, that's how I understand it. I am trying to convert the current time and date to the UTC format but just get an empty message box.

#include <date.au3> MsgBox(0,'Time', _Date_Time_GetSystemTimeAsFileTime())

Edited by benners, 10 August 2008 - 11:38 PM.








#2 PsaltyDS

PsaltyDS

    Most Venerable Penguin

  • MVPs
  • 13,279 posts

Posted 11 August 2008 - 12:46 AM

Is the function supposed to return the current date in the UTC format?, that's how I understand it. I am trying to convert the current time and date to the UTC format but just get an empty message box.

#include <date.au3> MsgBox(0,'Time', _Date_Time_GetSystemTimeAsFileTime())

That function returns a DLL structure, not a plain string. To convert:
#include <date.au3> $tCur = _Date_Time_GetSystemTime() MsgBox(0,'Time', _Date_Time_SystemTimeToDateTimeStr($tCur))


:P
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

#3 benners

benners

    Wayfarer

  • Active Members
  • Pip
  • 99 posts

Posted 11 August 2008 - 01:14 AM

That function returns a DLL structure, not a plain string. To convert:

#include <date.au3> $tCur = _Date_Time_GetSystemTime() MsgBox(0,'Time', _Date_Time_SystemTimeToDateTimeStr($tCur))


:P

Hi PsaltyDS,
I don't need the string I need the integer similar to when dates are converted to Epoch. I am trying to update a files time stamp and the format has to be VT_Filetime. With VBS the Now function sends the correct format but using AutoIt _Now() the update fails.

I did something a while ago for Paint Shop Pro
$iDateCalc = _DateDiff('s', "1970/01/01 00:00:00", _NowCalc())

the file accepts the update but the time is wrong it ended up bieng 30/07/1607 02:03:12

#4 PsaltyDS

PsaltyDS

    Most Venerable Penguin

  • MVPs
  • 13,279 posts

Posted 11 August 2008 - 03:50 PM

Hi PsaltyDS,
I don't need the string I need the integer similar to when dates are converted to Epoch. I am trying to update a files time stamp and the format has to be VT_Filetime. With VBS the Now function sends the correct format but using AutoIt _Now() the update fails.

I did something a while ago for Paint Shop Pro

$iDateCalc = _DateDiff('s', "1970/01/01 00:00:00", _NowCalc())

the file accepts the update but the time is wrong it ended up bieng 30/07/1607 02:03:12

File times are not seconds since Epoch, they are 64bit integer 0.1usecs ticks since 01/01/1601. See $tagFILETIME (also MSDN) in the help file, which is the structure you got back from _Date_Time_GetSystemTimeAsFileTime() in the first place:
#include <Date.au3> ; $tagFILETIME = "dword Lo;dword Hi" $structFILETIME = _Date_Time_GetSystemTimeAsFileTime() ConsoleWrite("Debug: Lo = " & DllStructGetData($structFILETIME, "Lo") & @LF) ConsoleWrite("Debug: Hi = " & DllStructGetData($structFILETIME, "Hi") & @LF) $sFILETIME = "0x" & Hex(DllStructGetData($structFILETIME, "Hi"), 8) & Hex(DllStructGetData($structFILETIME, "Lo"), 8) ConsoleWrite("Debug: 0.1 microsecond ticks since January 01, 1601 = " & $sFILETIME & @LF)


:P

Edited by PsaltyDS, 11 August 2008 - 03:51 PM.

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

#5 benners

benners

    Wayfarer

  • Active Members
  • Pip
  • 99 posts

Posted 11 August 2008 - 04:19 PM

File times are not seconds since Epoch, they are 64bit integer 0.1usecs ticks since 01/01/1601. See $tagFILETIME (also MSDN) in the help file, which is the structure you got back from _Date_Time_GetSystemTimeAsFileTime() in the first place:

#include <Date.au3> ; $tagFILETIME = "dword Lo;dword Hi" $structFILETIME = _Date_Time_GetSystemTimeAsFileTime() ConsoleWrite("Debug: Lo = " & DllStructGetData($structFILETIME, "Lo") & @LF) ConsoleWrite("Debug: Hi = " & DllStructGetData($structFILETIME, "Hi") & @LF) $sFILETIME = "0x" & Hex(DllStructGetData($structFILETIME, "Hi"), 8) & Hex(DllStructGetData($structFILETIME, "Lo"), 8) ConsoleWrite("Debug: 0.1 microsecond ticks since January 01, 1601 = " & $sFILETIME & @LF)


:P

That's what I wanted in the first place :-) but the value returned from _Date_Time_GetSystemTimeAsFileTime is blank, how do I display this info?.
I tried your code above and it obviously works but the returned value is not accepted to update the file. Both DllStructGetData($structFILETIME, "Lo") and DllStructGetData($structFILETIME, "Hi") return values that are accepted but the new file time is still wrong the year is 1607, do I have to do some conversion to return a 64 integer that equates to todays current time and date?

Thanks for your help

#6 PsaltyDS

PsaltyDS

    Most Venerable Penguin

  • MVPs
  • 13,279 posts

Posted 11 August 2008 - 04:40 PM

That's what I wanted in the first place :-) but the value returned from _Date_Time_GetSystemTimeAsFileTime is blank, how do I display this info?.
I tried your code above and it obviously works but the returned value is not accepted to update the file. Both DllStructGetData($structFILETIME, "Lo") and DllStructGetData($structFILETIME, "Hi") return values that are accepted but the new file time is still wrong the year is 1607, do I have to do some conversion to return a 64 integer that equates to todays current time and date?

Thanks for your help


You haven't said yet what function you are using to set the file time, have you? Anyway, it probably wants the $structFILETIME as an input (or a pointer to it), not just parts of it. We don't know until we see how you are using it...

:P
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

#7 benners

benners

    Wayfarer

  • Active Members
  • Pip
  • 99 posts

Posted 11 August 2008 - 07:27 PM

You haven't said yet what function you are using to set the file time, have you? Anyway, it probably wants the $structFILETIME as an input (or a pointer to it), not just parts of it. We don't know until we see how you are using it...

:P

The file is an MSI, I am creating a Windows.Installer object then opening the database and updating the MSI files time stamp. The accepted format for the property I am updating is VT_FILETIME and if using VB Script the Now Function returns a correct format to update the file, what I am trying to to o is return the VT_FILETIME format which is a 64bit integer as you said previously.

The part of the code that updates the file time is $nValue, this is supplied to the function as a parameter
 $SumInfo = $obj.SummaryInformation($MSP2Read, 1); Read the summary information $SumInfo.Property($iProperty) = $nValue $SumInfo.Persist

So I am trying to supply an integer that does not fail and sets the current date and time.

Thanks

Edited by benners, 11 August 2008 - 07:27 PM.


#8 PsaltyDS

PsaltyDS

    Most Venerable Penguin

  • MVPs
  • 13,279 posts

Posted 12 August 2008 - 12:00 AM

The file is an MSI, I am creating a Windows.Installer object then opening the database and updating the MSI files time stamp. The accepted format for the property I am updating is VT_FILETIME and if using VB Script the Now Function returns a correct format to update the file, what I am trying to to o is return the VT_FILETIME format which is a 64bit integer as you said previously.

The part of the code that updates the file time is $nValue, this is supplied to the function as a parameter

 $SumInfo = $obj.SummaryInformation($MSP2Read, 1); Read the summary information $SumInfo.Property($iProperty) = $nValue $SumInfo.Persist

So I am trying to supply an integer that does not fail and sets the current date and time.

Thanks

It still looks to me like it is a DLL struct, not a straight integer value that you should pass:
#include <date.au3> ; ... $tValue = _Date_Time_GetSystemTime() $SumInfo.Property($iProperty) = $tValue $SumInfo.Persist


Although I don't see anything that says that, it could want the pointer to the struct, which would be:
#include <date.au3> ; ... $tValue = _Date_Time_GetSystemTime() $SumInfo.Property($iProperty) = DllStructGetPtr($tValue) $SumInfo.Persist


:P
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

#9 benners

benners

    Wayfarer

  • Active Members
  • Pip
  • 99 posts

Posted 12 August 2008 - 06:24 PM

It still looks to me like it is a DLL struct, not a straight integer value that you should pass:

#include <date.au3> ; ... $tValue = _Date_Time_GetSystemTime() $SumInfo.Property($iProperty) = $tValue $SumInfo.Persist


Although I don't see anything that says that, it could want the pointer to the struct, which would be:
#include <date.au3> ; ... $tValue = _Date_Time_GetSystemTime() $SumInfo.Property($iProperty) = DllStructGetPtr($tValue) $SumInfo.Persist


:P

I tried the code you posted but neither value was not accepted. I have been lookin through the help file and normally steer clear of DLL things but would it work if I used DllStructCreate, something like he code below, I don't know if the format is correct and haven't tried this variation.

 $a = DllStructCreate('uint64') DllStructSetData($a,"", _Date_Time_GetSystemTimeAsFileTime())


Thanks

Edited by benners, 12 August 2008 - 06:25 PM.


#10 PsaltyDS

PsaltyDS

    Most Venerable Penguin

  • MVPs
  • 13,279 posts

Posted 12 August 2008 - 07:40 PM

I tried the code you posted but neither value was not accepted. I have been lookin through the help file and normally steer clear of DLL things but would it work if I used DllStructCreate, something like he code below, I don't know if the format is correct and haven't tried this variation.

 $a = DllStructCreate('uint64') DllStructSetData($a,"", _Date_Time_GetSystemTimeAsFileTime())


Thanks

I just don't know, maybe one of the smart people will chime in. The VT_FILETIME struct is clearly divided into 32bit "Hi" and "Lo" elements in the MSDN documentation (see link in post #4), and in AutoIt's $tagFILETIME, so it looked to me like that should have worked.

What OS and AutoIt versions are you using, and is the filesystem NTFS (not that I know it makes any difference)?

:P
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

#11 benners

benners

    Wayfarer

  • Active Members
  • Pip
  • 99 posts

Posted 12 August 2008 - 07:59 PM

I just don't know, maybe one of the smart people will chime in. The VT_FILETIME struct is clearly divided into 32bit "Hi" and "Lo" elements in the MSDN documentation (see link in post #4), and in AutoIt's $tagFILETIME, so it looked to me like that should have worked.

What OS and AutoIt versions are you using, and is the filesystem NTFS (not that I know it makes any difference)?

:P

I am using Win XP Pro, AutoIt v3.2.10.0 but compiling with the latest beta on NTFS. Thanks for your help I an going to keep playing with different functions and sending integers to see if I can blindly stumble on a solution :-)

Edited by benners, 12 August 2008 - 08:01 PM.


#12 GaryFrost

GaryFrost

    I don't need your attitude. I have one of my own

  • Developers
  • 7,854 posts

Posted 12 August 2008 - 08:59 PM

AutoIt         
#include <GuiConstantsEx.au3> #include <Date.au3> #include <WindowsConstants.au3> Global $iMemo _Main() Func _Main()     Local $hGUI, $tTime     ; Create GUI     $hGUI = GUICreate("Time", 400, 300)     $iMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)     GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")     GUISetState()     $tTime = _Date_Time_GetSystemTimeAsFileTime()     MemoWrite("Lo: " & DllStructGetData($tTime, "Lo"))     MemoWrite("High: " & DllStructGetData($tTime, "Hi"))     ; Loop until user exits     Do     Until GUIGetMsg() = $GUI_EVENT_CLOSE     EndFunc   ;==>_Main ; Write a line to the memo control Func MemoWrite($sMessage)     GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc   ;==>MemoWrite

SciTE for AutoItDirections for Submitting Standard UDFs

Don't argue with an idiot; people watching may not be able to tell the difference.


#13 PsaltyDS

PsaltyDS

    Most Venerable Penguin

  • MVPs
  • 13,279 posts

Posted 13 August 2008 - 02:40 AM

Plain Text         
#include <GuiConstantsEx.au3> #include <Date.au3> #include <WindowsConstants.au3> Global $iMemo _Main() Func _Main()     Local $hGUI, $tTime ; Create GUI     $hGUI = GUICreate("Time", 400, 300)     $iMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)     GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")     GUISetState()     $tTime = _Date_Time_GetSystemTimeAsFileTime()     MemoWrite("Lo: " & DllStructGetData($tTime, "Lo"))     MemoWrite("High: " & DllStructGetData($tTime, "Hi")) ; Loop until user exits     Do     Until GUIGetMsg() = $GUI_EVENT_CLOSE     EndFunc  ;==>_Main ; Write a line to the memo control Func MemoWrite($sMessage)     GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc  ;==>MemoWrite

Gary,
Thanks for the demo, but it shows the wrong end of the process for the OP. He was trying to figure out why passing the $tTime struct as an input parameter wasn't working. (See OP's post #7.)

:P
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

#14 ptrex

ptrex

    Universalist

  • MVPs
  • 2,408 posts

Posted 13 August 2008 - 07:20 AM

@Benners,

What you are after is reading the DateAndTime from the MSI records.

This will get you going.
GUICtrlSetData($Listbox1, "Last Printed: " & WMIDateStringToDateTime_EURO($SumInfo.Property(11)) ) GUICtrlSetData($Listbox1, "Creation Date: " & WMIDateStringToDateTime_EURO($SumInfo.Property(12)) ) GUICtrlSetData($Listbox1, "Last Saved: " & WMIDateStringToDateTime_EURO($SumInfo.Property(13)) ) ; Date and Time conversion Func WMIDateStringToDateTime_EURO($dtmDate)     Return(StringRegExpReplace($dtmDate, "\A(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(?:.*)","$1/$2/$3 $4:$5:$6")) EndFunc



Look also in my signature for the MSI browser. Run it and click on summary information.

regards,

ptrex

#15 ptrex

ptrex

    Universalist

  • MVPs
  • 2,408 posts

Posted 13 August 2008 - 07:22 AM

@Benners,

What you are after is reading the DateAndTime from the MSI records.

This will get you going.
GUICtrlSetData($Listbox1, "Last Printed: " & WMIDateStringToDateTime_EURO($SumInfo.Property(11)) ) GUICtrlSetData($Listbox1, "Creation Date: " & WMIDateStringToDateTime_EURO($SumInfo.Property(12)) ) GUICtrlSetData($Listbox1, "Last Saved: " & WMIDateStringToDateTime_EURO($SumInfo.Property(13)) ) ; Date and Time conversion Func WMIDateStringToDateTime_EURO($dtmDate)     Return(StringRegExpReplace($dtmDate, "\A(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(?:.*)","$1/$2/$3 $4:$5:$6")) EndFunc



Look also in my signature for the MSI browser. Run it and click on summary information.

regards,

ptrex

#16 benners

benners

    Wayfarer

  • Active Members
  • Pip
  • 99 posts

Posted 13 August 2008 - 08:37 PM

@Benners,

What you are after is reading the DateAndTime from the MSI records.

This will get you going.

GUICtrlSetData($Listbox1, "Last Printed: " & WMIDateStringToDateTime_EURO($SumInfo.Property(11)) ) GUICtrlSetData($Listbox1, "Creation Date: " & WMIDateStringToDateTime_EURO($SumInfo.Property(12)) ) GUICtrlSetData($Listbox1, "Last Saved: " & WMIDateStringToDateTime_EURO($SumInfo.Property(13)) ) ; Date and Time conversion Func WMIDateStringToDateTime_EURO($dtmDate)     Return(StringRegExpReplace($dtmDate, "\A(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(?:.*)","$1/$2/$3 $4:$5:$6")) EndFunc



Look also in my signature for the MSI browser. Run it and click on summary information.

regards,

ptrex

Thanks all for the replies,
@ptrex
I originally tried something similar but just by sending @year & @mon etc but as PsaltyDS mentioned it needs to be an integer to update the date.

I have been trying to find out how the VB Script "Now" function works as in a vbs script that is how the time stamp is updated but couldn't find anything, the closest I came was an archived page that may or may not be relevant. I tried to emulate what it did with AutoIt but it didn't work either I am doing it wrong (most likely) or it would not work anyway.

I have decided to put this on the back burner as it is wasting my time at the moment but below is the script I have been trying to use. The commented code are previous attempts and the latest is the date calc one.
Plain Text         
#include <Date.au3> ; When applied to MSI ; $t1                      = 16/07/1607 01:08:13 ; $t2                      = 26/07/1607 06:25:39 ; $tTime                    = Error ; $t1 * 65535 * 65535 + $t2 = 25/07/1607 11:20:19 ; $tStamp                  = 11/08/1607 05:09:24 ; $iDateCalc                = 15/07/1607 15:35:34 using 1ns as 1000000000 ;                          = 25/07/1607 00:50:24 using 100-ns intervals as 10000000 ? #cs $structFILETIME  = _Date_Time_GetSystemTimeAsFileTime() $t1 = "0x" & Hex(DllStructGetData($structFILETIME, "Hi"), 8) $t2 = Hex(DllStructGetData($structFILETIME, "Lo"), 8) $a = DllStructCreate('double') DllStructSetData($a, 1, $t1) $b = DllStructCreate('double') DllStructSetData($b, 1, $t2) $t3 = DllStructGetData($a, 1, 1) $t4 = DllStructGetData($b, 1, 1) $tStamp = $t3 * 65535 * 65535 + $t4 #ce $iDateCalc = (_DateDiff( 's',"1601/01/01 00:00:00",_NowCalc()) * 10000000) MSI_SummaryInfo('C:\BackUp\STD.MSI', 13, $iDateCalc, 1) Func MSI_SummaryInfo($MSP2Read, $iProperty, $nValue = '', $iMode = 0); Get the summary info from an MSP ($MSP2Read = MSP file, $iProperty = Property string to get, $iMode = 0 Read info, 1 Update info).     Local $Installer, $SumInfo     $Installer = ObjCreate("WindowsInstaller.Installer"); Create a reference to the Windows Installer COM.     If Not IsObj($Installer) Then; Problem creating the COM object.     Else         If $iMode = 0 Then; Onlt read the Summary Info.             $SumInfo = $Installer.SummaryInformation($MSP2Read, 0); Read the summary information             Return $SumInfo.Property($iProperty); Return  the property string.         Else; Write new Summary Info.             $SumInfo = $Installer.SummaryInformation($MSP2Read, 1); Read the summary information             $SumInfo.Property($iProperty) = $nValue             $SumInfo.Persist         EndIf     EndIf EndFunc  ;==>MSI_SummaryInfo





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users