Convert GetFileTime results to day/month/year: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Added category links.)
m (64-bit compat)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{|align=right
{{PageAuthor|n0On3}}
|<small>Author: [[{{ns:2}}:n0On3|n0On3]] ([[{{ns:3}}:n0On3|talk]], [[{{ns:-1}}:Contributions/n0On3|contrib]])</small>
 
|}
<br style="clear:both;">
== Description ==
== Description ==
Use this code to convert the dword you get in GetFileTime:
Use this code to convert the dword you get in GetFileTime:
Line 12: Line 10:
System::Int64Op $1 + $0
System::Int64Op $1 + $0
Pop $0
Pop $0
System::Call "*(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) i .r1"
System::Call "*(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2)p.r1"
System::Call "Kernel32::FileTimeToSystemTime(*l r0, i r1)"
System::Call "Kernel32::FileTimeToSystemTime(*l r0, p r1)"
System::Call "Kernel32::GetDateFormatA(i 0, i 0, i r1, t 'dd/MM/yy', t .r0, i ${NSIS_MAX_STRLEN})"
System::Call "Kernel32::GetDateFormat(i 0, i 0, p r1, t 'dd/MM/yy', t .r0, i ${NSIS_MAX_STRLEN})"
System::Free $1
DetailPrint $0 # print results
DetailPrint $0 # print results
</highlight-nsis>
</highlight-nsis>
Line 23: Line 22:
Here's the [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_5w6s.asp list of variables]. This example uses "dd/MM/yy".
Here's the [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_5w6s.asp list of variables]. This example uses "dd/MM/yy".


[[{{ns:14}}:System Plugin Examples]]
[[Category:System Plugin Examples]]

Latest revision as of 12:50, 30 September 2022

Author: n0On3 (talk, contrib)


Description

Use this code to convert the dword you get in GetFileTime:

The Script

GetFileTime "$INSTDIR\file.txt" $1 $0
System::Int64Op $1 * 0x100000000
Pop $1
System::Int64Op $1 + $0
Pop $0
System::Call "*(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2)p.r1"
System::Call "Kernel32::FileTimeToSystemTime(*l r0, p r1)"
System::Call "Kernel32::GetDateFormat(i 0, i 0, p r1, t 'dd/MM/yy', t .r0, i ${NSIS_MAX_STRLEN})"
System::Free $1
DetailPrint $0 # print results

(coded by Kichik)

You should use $1 and $0 because that's what System::Call uses internally.

Here's the list of variables. This example uses "dd/MM/yy".