Written into a normal Windows UI, a time stamp utility for setting file times.
See below for updated version.
:thumbsup: :thumbsup: :thumbsup:
Hi Hutch!
Selected LocalTime is 10 hour
SystemTime is 13 hour
but file is setted to 7 hour!!
-----------------------------
Selected SystemTime is 13 hour
but file is setted to 10 hour!!
Apparently "SystemTimeToFileTime" make a correction to local time, the correct function "LocalTimeToFileTime" doesn't exist.
Hi Hector,
It seems that the hour as set in the text box is not being converted correctly. I set the structure member as follows,
rcall GetWindowText,hHour,pbuf,64
mov rax, uval(pbuf)
mov stm.wHour, ax
Then follow it with,
invoke SystemTimeToFileTime,pstm,pftm
rcall SleepEx,256,0 ; needs to have this delay
invoke SetFileTime,hFile,pftm,pftm,pftm
Perhaps the API SystemTimeToFileTime is broken.
Quote from: hutch-- on August 18, 2022, 01:38:56 AM
Perhaps the API SystemTimeToFileTime is broken.
They just made that way, because they like these wanderings paths :biggrin:
TzSpecificLocalTimeToSystemTime function must be used first:
; ---------------------------------------------
mov hFile, flopen(pTxt) ; open file to modify
invoke TzSpecificLocalTimeToSystemTime, NULL, pstm, pstml
invoke SystemTimeToFileTime,pstml,pftm
rcall SleepEx,256,0 ; needs to have this delay
invoke SetFileTime,hFile,pftm,pftm,pftm
invoke MessageBox,hWnd,LastError$(),pTxt,MB_OK ; last error result
flclose hFile ; close file
With option GetSystemTime it works fine.
Quote from: HSE on August 18, 2022, 02:47:14 AM
TzSpecificLocalTimeToSystemTime function must be used first:
This is only necessary with option GetLocalTime.
Strange that there is no hint in the documentation ...
Hi Greenhorn
SystemTimeToFileTime is converting values in boxes to local time (like if that values are UTC 0).
Quote from: Greenhorn on August 18, 2022, 05:26:51 AM
With option GetSystemTime it works fine.
Are you in UTC 0 (or at least your computer think that) ?
Quote from: Greenhorn on August 18, 2022, 05:26:51 AMThis is only necessary with option GetLocalTime.
See here (http://masm32.com/board/index.php?topic=10273.msg112209#msg112209)
HSE
Quote from: HSE on August 18, 2022, 06:08:42 AM
Hi Greenhorn
SystemTimeToFileTime is converting values in boxes to local time (like if that values are UTC 0).
Quote from: Greenhorn on August 18, 2022, 05:26:51 AM
With option GetSystemTime it works fine.
Are you in UTC 0 (or at least your computer think that) ?
I'm in UTC +2 (Central European Summer Time).
Hi Hector,
This line,
invoke TzSpecificLocalTimeToSystemTime, NULL, pstm, pstm
Has done the job here, the hour as set in the text boxes ends up as the right time in the file listing in Winfile and Explorer. :thumbsup: :eusa_clap: :biggrin:
Attached is the version with Hector's mod.