martin Posted November 30, 2006 Posted November 30, 2006 I want to know the time stamp of a file obtained using FTPGetFile. I can get the FileTime values in the FileTime struct, but do not know how to convert it to time. There is a function in kernell32.dll called FileTimeToDosDateTime but I have no idea how to use it and my experiments with it have got me nowhere. I've tried the following but no good. Can anyone tell me what I should write? $date = '' $time = '' dllcall('kernell32.dll','int','FileTimeToDosDateTime','ptr',DllStructGetPtr(DllStructGetData($WIN32_FIND_DATA, 4)),"int",$date,'int',$time) msgbox(0,'kernell32.dll set @error to',@error);--> gives @error = 1 msgbox(0,$date,$time);-->both empty strings Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
eynstyne Posted November 30, 2006 Posted November 30, 2006 You have mispelled kernel! (kernel32.dll) F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent]
martin Posted November 30, 2006 Author Posted November 30, 2006 You have mispelled kernel! (kernel32.dll)Thanks. Now it crashes unless I use int64 like thisdllcall('kernel32.dll','int64','FileTimeToDosDateTime','ptr',DllStructGetPtr(DllStructGetData($WIN32_FIND_DATA, 4)),"int",$date,'int',$time)But otherwise no improvement. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
PaulIA Posted November 30, 2006 Posted November 30, 2006 Thanks. Now it crashes unless I use int64 like this dllcall('kernel32.dll','int64','FileTimeToDosDateTime','ptr',DllStructGetPtr(DllStructGetData($WIN32_FIND_DATA, 4)),"int",$date,'int',$time) But otherwise no improvement.Here is the file time to local time function from Auto3Lib (A3LWinAPI.au3). There are some more time functions there too if your interested. ; ================================================================================================= ; Description ..: Converts a file time based on the Coordinated Universal Time to a local file time ; Parameters ...: $rFileTime - FILETIME structure containing the UTC-based file time to convert ; into a local file time. ; Return values : FILETIME structure that contains the converted local file time ; ================================================================================================= Func _FileTimeToLocalFileTime($rFileTime) Local $pFileTime, $pLocalTime, $rLocalTime, $aResult $rLocalTime = DllStructCreate($FILETIME ) $pLocalTime = DllStructGetPtr($rLocalTime) $pFileTime = DllStructGetPtr($rFileTime ) $aResult = DllCall("Kernel32.dll", "int", "FileTimeToLocalFileTime", "ptr", $pFileTime, _ "ptr", $pLocalTime) Return $rLocalTime EndFunc Auto3Lib: A library of over 1200 functions for AutoIt
Developers Jos Posted November 30, 2006 Developers Posted November 30, 2006 Maybe I am missing something but what is wrong with FileGetTime() ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
martin Posted November 30, 2006 Author Posted November 30, 2006 (edited) Maybe I am missing something but what is wrong with FileGetTime() ?@JdeB FileGetTime is for windows so to use it I would need to download the file and then find its timestamp. But I am trying to get the timestamp of a file using ftp, (InternetFindNextFile), without having to download it, so I end up with a FileTime struct. But maybe there is a better way.@PaulIAThat's just what I was looking for - thanks, I'll tryit. Edited November 30, 2006 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
martin Posted November 30, 2006 Author Posted November 30, 2006 (edited) I have tried using PaulIA's functions but get an error. I tried this- Local $callFindNext = DllCall('wininet.dll', 'int', 'InternetFindNextFile', 'long', $callFindFirst[0], 'ptr', _ DllStructGetPtr($WIN32_FIND_DATA)) ;works ok I think and the struct $WIN32_FIND_DATA has the FileTime struct in element 4. $datetime = _FileTimeToSystemTime(_FileTimeToLocalFileTime(DllStructGetData($WIN32_FIND_DATA, 4))) I get [error - DllStructGetPtr: 1] when the function below runs Func _FileTimeToLocalFileTime($rFileTime) Local $pFileTime, $pLocalTime, $rLocalTime Local $hKernel32, $aResult $rLocalTime = _DllStructCreate($FILETIME ) $pLocalTime = _DllStructGetPtr($rLocalTime) $pFileTime = _DllStructGetPtr($rFileTime );<-------------something wrong with the $rFileTime struct?? $hKernel32 = _DllOpen("Kernel32.dll") $aResult = DllCall($hKernel32, "int", "FileTimeToLocalFileTime", "ptr", $pFileTime, _ "ptr", $pLocalTime) _Check("_FileTimeToLocalFileTime:DllCall", @Error, @Error) _Check("_FileTimeToLocalFileTime:FileTimeToLocalFileTime", ($aResult[0] = 0), 0, True) Return $rLocalTime EndFunc Any ideas? Edited November 30, 2006 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
PaulIA Posted November 30, 2006 Posted November 30, 2006 I have tried using PaulIA's functions but get an error. I tried this- Local $callFindNext = DllCall('wininet.dll', 'int', 'InternetFindNextFile', 'long', $callFindFirst[0], 'ptr', _ DllStructGetPtr($WIN32_FIND_DATA)) ;works ok I think and the struct $WIN32_FIND_DATA has the FileTime struct in element 4. $datetime = _FileTimeToSystemTime(_FileTimeToLocalFileTime(DllStructGetData($WIN32_FIND_DATA, 4))) I get [error - DllStructGetPtr: 1] when the function below runs Func _FileTimeToLocalFileTime($rFileTime) Local $pFileTime, $pLocalTime, $rLocalTime Local $hKernel32, $aResult $rLocalTime = _DllStructCreate($FILETIME ) $pLocalTime = _DllStructGetPtr($rLocalTime) $pFileTime = _DllStructGetPtr($rFileTime );<-------------something wrong with the $rFileTime struct?? $hKernel32 = _DllOpen("Kernel32.dll") $aResult = DllCall($hKernel32, "int", "FileTimeToLocalFileTime", "ptr", $pFileTime, _ "ptr", $pLocalTime) _Check("_FileTimeToLocalFileTime:DllCall", @Error, @Error) _Check("_FileTimeToLocalFileTime:FileTimeToLocalFileTime", ($aResult[0] = 0), 0, True) Return $rLocalTime EndFunc Any ideas?Your getting the error because you're not passing a $FILETIME structure to the UDF. You need to do something like: $rFileTime = DLLStructCreate($FILETIME) DllStructSetData($rFileTime, 1, DLLStructGetData($WIN32_FIND_DATA, 4)) $datetime = _FileTimeToSystemTime($rFileTime) If you're still stuck, look at how this call is used in A3LEventLog.au3 to convert the event record date/time. Auto3Lib: A library of over 1200 functions for AutoIt
Developers Jos Posted November 30, 2006 Developers Posted November 30, 2006 (edited) My vote goes to the Underscore infront of the internal Dll functions... Edited November 30, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
PaulIA Posted November 30, 2006 Posted November 30, 2006 My vote goes to the Underscore infront of the internal Dll functions...He's using some of the overloaded Auto3Lib functions (which are being removed in the next release). They just call the AutoIt function and do some automated error checking. The help file has this to say about DllStructPtr errors: @Error: 0 = No Error. 1 = Struct not a correct struct returned by DllStructCreate. 2 = Element is out of bounds. Auto3Lib: A library of over 1200 functions for AutoIt
martin Posted November 30, 2006 Author Posted November 30, 2006 Your getting the error because you're not passing a $FILETIME structure to the UDF. You need to do something like: $rFileTime = DLLStructCreate($FILETIME) DllStructSetData($rFileTime, 1, DLLStructGetData($WIN32_FIND_DATA, 4)) $datetime = _FileTimeToSystemTime($rFileTime) If you're still stuck, look at how this call is used in A3LEventLog.au3 to convert the event record date/time. Thanks PaulIA, I think I must be close. Your functions and examples are a real help. I still can't get a sensible result but at least no crashes now. Here's my latest attempt, copying or using your code $fd= DLLStructCreate($FILETIME) DllStructSetData($fd, 1, DLLStructGetData($WIN32_FIND_DATA, 4)) $date = _FileTimeToLocalFileTime($fd) $datetime = _FileTimeToSystemTime($date) $iMonth = _DllStructGetData($datetime, $ST_MONTH) $iDay = _DllStructGetData($datetime, $ST_DAY ) $iYear = _DllStructGetData($datetime, $ST_YEAR ) $iHours = _DllStructGetData($datetime, $ST_HOUR ) $iMinutes = _DllStructGetData($datetime, $ST_MINUTE) $iSeconds = _DllStructGetData($datetime, $ST_SECOND) $sAMPM = 'AM' if $iHours > 11 then $sAMPM = "PM" $iHours = $iHours - 12 endif $shout = StringFormat("%2d/%2d/%4d at %02d:%02d:%02d %s", $iDay, $iMonth, $iYear, _ $iMinutes,$iHours, $iSeconds, $sAMPM) msgbox(0,'date read = ',$shout) The result in the msgbox is something like 1/1/1601 at 0:0:1:24 The date is always 1/1/1601 and the time varies, ( and I'm fairly sure the files aren't that old.) 1/1/1601 means the date value is always zero so I'm lost again. Is it possible that the server doen't use UTC format? It's a UNIX system. I'll check this Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
PaulIA Posted November 30, 2006 Posted November 30, 2006 Thanks PaulIA, I think I must be close. Your functions and examples are a real help. I still can't get a sensible result but at least no crashes now. Here's my latest attempt, copying or using your code $fd= DLLStructCreate($FILETIME) DllStructSetData($fd, 1, DLLStructGetData($WIN32_FIND_DATA, 4)) $date = _FileTimeToLocalFileTime($fd) $datetime = _FileTimeToSystemTime($date) $iMonth = _DllStructGetData($datetime, $ST_MONTH) $iDay = _DllStructGetData($datetime, $ST_DAY ) $iYear = _DllStructGetData($datetime, $ST_YEAR ) $iHours = _DllStructGetData($datetime, $ST_HOUR ) $iMinutes = _DllStructGetData($datetime, $ST_MINUTE) $iSeconds = _DllStructGetData($datetime, $ST_SECOND) $sAMPM = 'AM' if $iHours > 11 then $sAMPM = "PM" $iHours = $iHours - 12 endif $shout = StringFormat("%2d/%2d/%4d at %02d:%02d:%02d %s", $iDay, $iMonth, $iYear, _ $iMinutes,$iHours, $iSeconds, $sAMPM) msgbox(0,'date read = ',$shout) The result in the msgbox is something like 1/1/1601 at 0:0:1:24 The date is always 1/1/1601 and the time varies, ( and I'm fairly sure the files aren't that old.) 1/1/1601 means the date value is always zero so I'm lost again. Is it possible that the server doen't use UTC format? It's a UNIX system. I'll check this_FileTimeToLocalFileTime converts a file time to a local time and _FileTimeToSystemTime converts a file time to a system time. I don't think you want to call one with the results of the other. To test, just call _FileTimeToLocalFileTime and display the results. Then do the same with _FileTimeToSystemTime. I'm betting one of them will get you what you want. Auto3Lib: A library of over 1200 functions for AutoIt
martin Posted November 30, 2006 Author Posted November 30, 2006 _FileTimeToLocalFileTime converts a file time to a local time and _FileTimeToSystemTime converts a file time to a system time. I don't think you want to call one with the results of the other. To test, just call _FileTimeToLocalFileTime and display the results. Then do the same with _FileTimeToSystemTime. I'm betting one of them will get you what you want. Not a good bet! _FileTimeToLocalFileTime returns a FILETIME struct so I can' use that, and I think I'm correct to use its output in the _FileTimeToSystemTime function. Anyway, if I try as below then the result is exactly the same. $fd= DLLStructCreate($FILETIME) DllStructSetData($fd, 1, DLLStructGetData($WIN32_FIND_DATA, 4,1)) DllStructSetData($fd, 2, DLLStructGetData($WIN32_FIND_DATA, 4,2)) ;2 lines above produce same as DllStructSetData($fd, 1, DLLStructGetData($WIN32_FIND_DATA, 4)) $datetime = _FileTimeToSystemTime($fd) $iMonth = _DllStructGetData($datetime, $ST_MONTH) $iDay = _DllStructGetData($datetime, $ST_DAY ) $iYear = _DllStructGetData($datetime, $ST_YEAR ) $iHours = _DllStructGetData($datetime, $ST_HOUR ) $iMinutes = _DllStructGetData($datetime, $ST_MINUTE) $iSeconds = _DllStructGetData($datetime, $ST_SECOND) $sAMPM = 'AM' if $iHours > 11 then $sAMPM = "PM" $iHours = $iHours - 12 endif $shout = StringFormat("%2d/%2d/%4d at %02d:%02d:%02d %s", $iDay, $iMonth, $iYear, $iHours, $iMinutes, $iSeconds, $sAMPM) Still stuck at 1/1/1601 It must be the FILETIME struct returned by ftpFileFindNext. The filetime structure is defined like this typedef struct _WIN32_FIND_DATA { DWORD dwFileAttributes; FILETIME ftCreationTime; FILETIME ftLastAccessTime; FILETIME ftLastWriteTime; DWORD nFileSizeHigh; DWORD nFileSizeLow; DWORD dwReserved0; DWORD dwReserved1; TCHAR cFileName[MAX_PATH]; TCHAR cAlternateFileName[14]; } In the FTP function the struct is created like this $str = "dword;int64;int64;int64;dword;dword;dword;dword;char[256];char[14]" $WIN32_FIND_DATA = DllStructCreate($str) I don't know if this is correct; it means int64 is being used for a filetime struct. Can anyone confirm that the structure is being correctly formed? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
PaulIA Posted November 30, 2006 Posted November 30, 2006 Not a good bet! The filetime structure is defined like this typedef struct _WIN32_FIND_DATA { DWORD dwFileAttributes; FILETIME ftCreationTime; FILETIME ftLastAccessTime; FILETIME ftLastWriteTime; DWORD nFileSizeHigh; DWORD nFileSizeLow; DWORD dwReserved0; DWORD dwReserved1; TCHAR cFileName[MAX_PATH]; TCHAR cAlternateFileName[14]; } In the FTP function the struct is created like this $str = "dword;int64;int64;int64;dword;dword;dword;dword;char[256];char[14]" $WIN32_FIND_DATA = DllStructCreate($str) I don't know if this is correct; it means int64 is being used for a filetime struct. Can anyone confirm that the structure is being correctly formed?FILETIME is defined in the SDK as: typedef struct tagFILETIME { DWORD dwLowDateTime; DWORD dwHighDateTime; } FILETIME; So the definition in the FTP function is not correct. That's probably causing the problem when you try to assign a 64 bit value to a structure with two 32 bit integers. Try changing the FTP function struct to 2 int values for each int64 value and see what you get. Auto3Lib: A library of over 1200 functions for AutoIt
/dev/null Posted November 30, 2006 Posted November 30, 2006 (edited) Try this:The function _FileTimeToSystemTime() expects a FILETIME Dll Structure. WARNING: No error checking implemented! I leave that up to you!!HINT: On my FTP server the creation time and last access time are allways set to 0. See also MSDN hint http://msdn.microsoft.com/library/default....nd_data_str.asp.ftCreationTime A FILETIME structure that specifies when a file or directory is created. If the underlying file system does not support creation time, this member is 0 (zero).expandcollapse popup#include <Ftp.au3> $FILETIME = "uint;uint" #cs typedef struct _FILETIME { DWORD dwLowDateTime; DWORD dwHighDateTime; } FILETIME, #ce $SYSTEMTIME = "ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort" #cs typedef struct _SYSTEMTIME { WORD wYear; WORD wMonth; WORD wDayOfWeek; WORD wDay; WORD wHour; WORD wMinute; WORD wSecond; WORD wMilliseconds; } SYSTEMTIME, #ce Func _FileTimeToSystemTime($structFileTime) Local $pFileTime, $pSystemTime, $aResult Dim $aReturn[9] $pFileTime = DllStructGetPtr($structFileTime) $structSystemTime = DllStructCreate($SYSTEMTIME) $pSystemTime = DllStructGetPtr($structSystemTime) $aResult = DllCall("Kernel32.dll", "int", "FileTimeToSystemTime", "ptr", $pFileTime, "ptr", $pSystemTime) $aReturn[0] = 8 $aReturn[1] = DllStructGetData($structSystemTime,1); Year $aReturn[2] = DllStructGetData($structSystemTime,2); Month $aReturn[3] = DllStructGetData($structSystemTime,3) ; Day of week $aReturn[4] = DllStructGetData($structSystemTime,4); Day $aReturn[5] = DllStructGetData($structSystemTime,5); Hour $aReturn[6] = DllStructGetData($structSystemTime,6); Minute $aReturn[7] = DllStructGetData($structSystemTime,7); Second $aReturn[8] = DllStructGetData($structSystemTime,8); Millisecond Return $aReturn EndFunc Func Failed($F) MsgBox(0, "FTP", "Failed on: " & $F) Exit 1 EndFunc ; MAIN PROGRAM $server = 'localhost' $username = 'test' $pass = 'test' $Open = _FTPOpen('MyFTP Control') If @error Then Failed("Open") $Conn = _FTPConnect($Open, $server, $username, $pass) If @error Then Failed("Connect") Dim $Handle Dim $DllRect $structFileTime = DllStructCreate($FILETIME) $FileInfo = _FtpFileFindFirst($Conn, '/*.*', $Handle, $DllRect) If $FileInfo[0] Then Do $create_time_low = $FileInfo[2] $create_time_high = $FileInfo[3] $access_time_low = $FileInfo[4] $access_time_high = $FileInfo[5] $modify_time_low = $FileInfo[6] $modify_time_high = $FileInfo[7] $file_name = $FileInfo[10] DllStructSetData($structFileTime,1,$modify_time_low) DllStructSetData($structFileTime,2,$modify_time_high) $aSystime = _FileTimeToSystemTime($structFileTime) $modify_date = StringFormat("%d-%02d-%02d %02d:%02d:%02d",$aSystime[1],$aSystime[2],$aSystime[4],$aSystime[5],$aSystime[6],$aSystime[7]) MsgBox(0,"FTP Files","Filename: " & $file_name & @CRLF & "Modify Date: " & $modify_date) $FileInfo = _FtpFileFindNext($Handle, $DllRect) Until Not $FileInfo[0] EndIfCheersKurt Edited December 1, 2006 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
martin Posted December 1, 2006 Author Posted December 1, 2006 Apologies but I made a mistake in my last post. This is what I meant to say The filetime structure is read from a WIN32_FIND_DATA struct which is defined like this typedef struct _WIN32_FIND_DATA { DWORD dwFileAttributes; FILETIME ftCreationTime; FILETIME ftLastAccessTime; FILETIME ftLastWriteTime; DWORD nFileSizeHigh; DWORD nFileSizeLow; DWORD dwReserved0; DWORD dwReserved1; TCHAR cFileName[MAX_PATH]; TCHAR cAlternateFileName[14]; } In the FTP function the IN32_FIND_DATA struct is created like this $str = "dword;int64;int64;int64;dword;dword;dword;dword;char[256];char[14]" $WIN32_FIND_DATA = DllStructCreate($str) I don't know if this is correct; it means int64 is being used for a filetime struct. Can anyone confirm that the structure is being correctly formed? ************SOLVED************************ I tried changing the struct to this $str = "dword;int[2];int[2];int[2];dword;dword;dword;dword;char[256];char[14]" $WIN32_FIND_DATA = DllStructCreate($str) and now it all works!! Thanks to everyon Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Jim Dandy Posted February 20, 2007 Posted February 20, 2007 Try this: The function _FileTimeToSystemTime() expects a FILETIME Dll Structure. WARNING: No error checking implemented! I leave that up to you!! HINT: On my FTP server the creation time and last access time are allways set to 0. See also MSDN hint http://msdn.microsoft.com/library/default....nd_data_str.asp. ftCreationTime A FILETIME structure that specifies when a file or directory is created. If the underlying file system does not support creation time, this member is 0 (zero). expandcollapse popup#include <Ftp.au3> $FILETIME = "uint;uint" #cs typedef struct _FILETIME { DWORD dwLowDateTime; DWORD dwHighDateTime; } FILETIME, #ce $SYSTEMTIME = "ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort" #cs typedef struct _SYSTEMTIME { WORD wYear; WORD wMonth; WORD wDayOfWeek; WORD wDay; WORD wHour; WORD wMinute; WORD wSecond; WORD wMilliseconds; } SYSTEMTIME, #ce Func _FileTimeToSystemTime($structFileTime) Local $pFileTime, $pSystemTime, $aResult Dim $aReturn[9] $pFileTime = DllStructGetPtr($structFileTime) $structSystemTime = DllStructCreate($SYSTEMTIME) $pSystemTime = DllStructGetPtr($structSystemTime) $aResult = DllCall("Kernel32.dll", "int", "FileTimeToSystemTime", "ptr", $pFileTime, "ptr", $pSystemTime) $aReturn[0] = 8 $aReturn[1] = DllStructGetData($structSystemTime,1); Year $aReturn[2] = DllStructGetData($structSystemTime,2); Month $aReturn[3] = DllStructGetData($structSystemTime,3) ; Day of week $aReturn[4] = DllStructGetData($structSystemTime,4); Day $aReturn[5] = DllStructGetData($structSystemTime,5); Hour $aReturn[6] = DllStructGetData($structSystemTime,6); Minute $aReturn[7] = DllStructGetData($structSystemTime,7); Second $aReturn[8] = DllStructGetData($structSystemTime,8); Millisecond Return $aReturn EndFunc Func Failed($F) MsgBox(0, "FTP", "Failed on: " & $F) Exit 1 EndFunc ; MAIN PROGRAM $server = 'localhost' $username = 'test' $pass = 'test' $Open = _FTPOpen('MyFTP Control') If @error Then Failed("Open") $Conn = _FTPConnect($Open, $server, $username, $pass) If @error Then Failed("Connect") Dim $Handle Dim $DllRect $structFileTime = DllStructCreate($FILETIME) $FileInfo = _FtpFileFindFirst($Conn, '/*.*', $Handle, $DllRect) If $FileInfo[0] Then Do $create_time_low = $FileInfo[2] $create_time_high = $FileInfo[3] $access_time_low = $FileInfo[4] $access_time_high = $FileInfo[5] $modify_time_low = $FileInfo[6] $modify_time_high = $FileInfo[7] $file_name = $FileInfo[10] DllStructSetData($structFileTime,1,$modify_time_low) DllStructSetData($structFileTime,2,$modify_time_high) $aSystime = _FileTimeToSystemTime($structFileTime) $modify_date = StringFormat("%d-%02d-%02d %02d:%02d:%02d",$aSystime[1],$aSystime[2],$aSystime[4],$aSystime[5],$aSystime[6],$aSystime[7]) MsgBox(0,"FTP Files","Filename: " & $file_name & @CRLF & "Modify Date: " & $modify_date) $FileInfo = _FtpFileFindNext($Handle, $DllRect) Until Not $FileInfo[0] EndIf Cheers Kurt I apologize if I am being totally stupid, but I would like to use this code, but you state that I must fist create a Filetime Dll Structure- which I am not sure how to do. Here's the situation: I have some filetime data that I am receiving in an XML document and I would like to convert it to user readable MM/DD/YYYY HH:MM:SS format. Here is an example of the data I receive: <CREATIONTIME> <HIGHPART>0x01C6FE83</HIGHPART> <LOWPART>0x92D51928</LOWPART> </CREATIONTIME> <LASTMODIFICATIONTIME> <HIGHPART>0x01C6FE97</HIGHPART> <LOWPART>0x395C54EA</LOWPART> </LASTMODIFICATIONTIME> I have been doing a lot of reading on this forum, MSDN, Google searches, etc. and I am somehow just not seeing the answer. Could someone do a little hand-holding for me and lead me to the answer without flaming me for being a dumbass?
PaulIA Posted February 20, 2007 Posted February 20, 2007 Here is an example using Auto3Lib and the values you provided above: #include <A3LTime.au3> Global $tFileTime, $tLocalTime, $aTime $tFileTime = __tagFileTime() _tagSetData($tFileTime, "Lo", 0x92D51928) _tagSetData($tFileTime, "Hi", 0x01C6FE83) $tLocalTime = _Time_FileTimeToLocalFileTime(_tagGetPtr($tFileTime)) $aTime = _Time_FileTimeToArray($tLocalTime) ConsoleWrite("Month ..: " & $aTime[0] & @CR) ConsoleWrite("Day ....: " & $aTime[1] & @CR) ConsoleWrite("Year ...: " & $aTime[2] & @CR) ConsoleWrite("Hour ...: " & $aTime[3] & @CR) ConsoleWrite("Minute .: " & $aTime[4] & @CR) ConsoleWrite("Seconds : " & $aTime[5] & @CR) Auto3Lib: A library of over 1200 functions for AutoIt
Jim Dandy Posted February 22, 2007 Posted February 22, 2007 Here is an example using Auto3Lib and the values you provided above: #include <A3LTime.au3> Global $tFileTime, $tLocalTime, $aTime $tFileTime = __tagFileTime() _tagSetData($tFileTime, "Lo", 0x92D51928) _tagSetData($tFileTime, "Hi", 0x01C6FE83) $tLocalTime = _Time_FileTimeToLocalFileTime(_tagGetPtr($tFileTime)) $aTime = _Time_FileTimeToArray($tLocalTime) ConsoleWrite("Month ..: " & $aTime[0] & @CR) ConsoleWrite("Day ....: " & $aTime[1] & @CR) ConsoleWrite("Year ...: " & $aTime[2] & @CR) ConsoleWrite("Hour ...: " & $aTime[3] & @CR) ConsoleWrite("Minute .: " & $aTime[4] & @CR) ConsoleWrite("Seconds : " & $aTime[5] & @CR) Thank you so much, I have taken the time to test this out and it works like a charm. Auto3Lib is quite impressive. I'm still trying to wrap my brain around many of the functions, but it's ingenious.
PaulIA Posted February 22, 2007 Posted February 22, 2007 Thank you so much, I have taken the time to test this out and it works like a charm. Auto3Lib is quite impressive. I'm still trying to wrap my brain around many of the functions, but it's ingenious.Glad I could help. If you get stuck trying to figure out a specific Auto3Lib function, feel free to drop a line in the Auto3Lib thread and I'll be glad to help you out. I'm also working on an AutoIt style help file that should be out in the next few weeks. Auto3Lib: A library of over 1200 functions for AutoIt
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