Author Topic: A File Time Stamp utility  (Read 586 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10005
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
A File Time Stamp utility
« 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.
« Last Edit: August 18, 2022, 10:21:35 AM by hutch-- »
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

stevenxie

  • Member
  • **
  • Posts: 55
Re: A File Time Stamp utility
« Reply #1 on: August 17, 2022, 06:49:30 PM »
 :thumbsup: :thumbsup: :thumbsup:

HSE

  • Member
  • *****
  • Posts: 2257
  • AMD 7-32 / i3 10-64
Re: A File Time Stamp utility
« Reply #2 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.
Equations in Assembly: SmplMath

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10005
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: A File Time Stamp utility
« Reply #3 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

HSE

  • Member
  • *****
  • Posts: 2257
  • AMD 7-32 / i3 10-64
Re: A File Time Stamp utility
« Reply #4 on: August 18, 2022, 02:47:14 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:
Code: [Select]
  ; ---------------------------------------------

    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

  • Member
  • ***
  • Posts: 434
Re: A File Time Stamp utility
« Reply #5 on: August 18, 2022, 05:26:51 AM »
With option GetSystemTime it works fine.

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

  • Member
  • *****
  • Posts: 2257
  • AMD 7-32 / i3 10-64
Re: A File Time Stamp utility
« Reply #6 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).

With option GetSystemTime it works fine.

Are you in UTC 0 (or at least your computer think that) ?


This is only necessary with option GetLocalTime.

See here

HSE
Equations in Assembly: SmplMath

Greenhorn

  • Member
  • ***
  • Posts: 434
Re: A File Time Stamp utility
« Reply #7 on: August 18, 2022, 09:54:02 AM »
Hi Greenhorn

SystemTimeToFileTime is converting values in boxes to local time (like if that values are UTC 0).

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--

  • Administrator
  • Member
  • ******
  • Posts: 10005
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: A File Time Stamp utility
« Reply #8 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: