benners Posted August 10, 2008 Share Posted August 10, 2008 (edited) 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 August 10, 2008 by benners Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 11, 2008 Share Posted August 11, 2008 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)) 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 Link to comment Share on other sites More sharing options...
benners Posted August 11, 2008 Author Share Posted August 11, 2008 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)) 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 Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 11, 2008 Share Posted August 11, 2008 (edited) 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) Edited August 11, 2008 by PsaltyDS 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 Link to comment Share on other sites More sharing options...
benners Posted August 11, 2008 Author Share Posted August 11, 2008 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) 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 Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 11, 2008 Share Posted August 11, 2008 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 helpYou 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... 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 Link to comment Share on other sites More sharing options...
benners Posted August 11, 2008 Author Share Posted August 11, 2008 (edited) 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... 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 August 11, 2008 by benners Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 12, 2008 Share Posted August 12, 2008 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 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 Link to comment Share on other sites More sharing options...
benners Posted August 12, 2008 Author Share Posted August 12, 2008 (edited) 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 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 August 12, 2008 by benners Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 12, 2008 Share Posted August 12, 2008 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)? 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 Link to comment Share on other sites More sharing options...
benners Posted August 12, 2008 Author Share Posted August 12, 2008 (edited) 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)? 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 August 12, 2008 by benners Link to comment Share on other sites More sharing options...
GaryFrost Posted August 12, 2008 Share Posted August 12, 2008 #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.  Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 13, 2008 Share Posted August 13, 2008 #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.) 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 Link to comment Share on other sites More sharing options...
ptrex Posted August 13, 2008 Share Posted August 13, 2008 @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 Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
ptrex Posted August 13, 2008 Share Posted August 13, 2008 @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 Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
benners Posted August 13, 2008 Author Share Posted August 13, 2008 @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, ptrexThanks 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. expandcollapse popup#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 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now