The MASM Forum

Members Gallery => Showcase => Topic started by: hutch-- on August 17, 2022, 12:43:52 PM

Title: A File Time Stamp utility
Post by: hutch-- on August 17, 2022, 12:43:52 PM
Written into a normal Windows UI, a time stamp utility for setting file times.

See below for updated version.
Title: Re: A File Time Stamp utility
Post by: stevenxie on August 17, 2022, 06:49:30 PM
 :thumbsup: :thumbsup: :thumbsup:
Title: Re: A File Time Stamp utility
Post by: HSE on August 17, 2022, 11:27:28 PM
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.
Title: Re: A File Time Stamp utility
Post by: hutch-- on August 18, 2022, 01:38:56 AM
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.
Title: Re: A File Time Stamp utility
Post by: HSE on August 18, 2022, 02:47:14 AM
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
Title: Re: A File Time Stamp utility
Post by: Greenhorn on August 18, 2022, 05:26:51 AM
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 ...
Title: Re: A File Time Stamp utility
Post by: 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) ?


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
Title: Re: A File Time Stamp utility
Post by: Greenhorn on August 18, 2022, 09:54:02 AM
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).
Title: Re: A File Time Stamp utility
Post by: hutch-- on August 18, 2022, 10:03:29 AM
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.