News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

A File Time Stamp utility

Started by hutch--, August 17, 2022, 12:43:52 PM

Previous topic - Next topic

hutch--

Written into a normal Windows UI, a time stamp utility for setting file times.

See below for updated version.


HSE

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.
Equations in Assembly: SmplMath

hutch--

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.

HSE

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
Equations in Assembly: SmplMath

Greenhorn

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 ...
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

HSE

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

HSE
Equations in Assembly: SmplMath

Greenhorn

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).
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

hutch--

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.