-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRDCCompileDateTime.pkg
More file actions
167 lines (137 loc) · 6.52 KB
/
Copy pathRDCCompileDateTime.pkg
File metadata and controls
167 lines (137 loc) · 6.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
Package with general purpose function "ProgramCompileDate" that returns
the running program's date & time.
See: Function ProgramCompileDate at end of package.
*/
Use RDCCompileDateTime.h.pkg
Class cFileCompileDateAndTime is a cObject
Procedure Construct_Object
Forward Send Construct_Object
End_Procedure
// Pass the sFileName with full path
// Returns the date & time when it was created.
Function CreationFileCompilationTime String sFileName Returns DateTime
tWinFileTime FileTime
DateTime dtFileTime
tWin32FindDataW Win32FindData
tFileDateTime FileDateTime
Handle hFile
Integer iRetval iErrorNumber iVoid
String sCompileTime
Move "" to sCompileTime
Move 0 to iVoid
Move (winFindFirstFileW (sFileName, AddressOf(Win32FindData))) to hFile
If (hFile = INVALID_HANDLE_VALUE) Begin
Move (GetLastError()) to iErrorNumber
If (iErrorNumber <> 0) Begin
Send ShowCompileTimeFileError iErrorNumber sFileName
End
End
Move (PointerToWString (AddressOf(Win32FindData) + SizeOfType (tWin32FindData) - MAX_PATH - MAX_ALTPATH)) to FileDateTime.sFileName
Move Win32FindData.dwFileAttributes to FileDateTime.iAttributes
Get ConvertDateTimeToSystemDateTime Win32FindData.ftCreationTime.dwLowDateTime Win32FindData.ftCreationTime.dwHighDateTime to FileDateTime.dtCreated
Move (winFindClose (hFile)) to iVoid
Function_Return FileDateTime.dtCreated
End_Function
Function ConvertDateTimeToSystemDateTime UInteger dwLowDateTime UInteger dwHighDateTime Returns DateTime
WString sFormattedTime sFormattedDate
Integer iSuccess iDataLength
tWinSystemTime SystemTime
tWinFileTime FileTime
DateTime dtResult
Move dwLowDateTime to FileTime.dwLowDateTime
Move dwHighDateTime to FileTime.dwHighDateTime
Move (CompileTimeFileFileTimeToSystemTime (AddressOf (FileTime), AddressOf (SystemTime))) to iSuccess
If (iSuccess <> 0) Begin
Get SystemTimeToDateTime SystemTime to dtResult
// We don't care about milli seconds:
Move (DateSetMillisecond(dtResult, 0)) to dtResult
End
Function_Return dtResult
End_Function
Function SystemTimeToDateTime tWinSystemTime SystemTime Returns DateTime
String sFormattedTime sFormattedDate
Integer iDecimalSeparator
DateTime dtResult
Get FormatSystemTimeToTime SystemTime to sFormattedTime
If (SystemTime.wMilliseconds > 0) Begin
Get_Attribute DF_DECIMAL_SEPARATOR to iDecimalSeparator
Move (sFormattedTime + Character (iDecimalSeparator) + Cast (SystemTime.wMilliseconds, String)) to sFormattedTime
End
Get FormatSystemTimeToDate SystemTime to sFormattedDate
Move (sFormattedDate * sFormattedTime) to dtResult
Function_Return dtResult
End_Function
Function FormatSystemTimeToDate tWinSystemTime SystemTime Returns Date
Integer iDataLength
WString wsFormattedDate wsLocaleName
Date dFormattedDate
Move "" to wsLocaleName
Move (CompileTimeGetDateFormatEx (AddressOf (wsLocaleName), 0, AddressOf (SystemTime), 0, 0, 0, 0)) to iDataLength
Move (ZeroString (iDataLength)) to wsFormattedDate
Move (CompileTimeGetDateFormatEx (AddressOf (wsLocaleName), 0, AddressOf (SystemTime), 0, AddressOf (wsFormattedDate), iDataLength, 0)) to iDataLength
Move (Date (Cstring (wsFormattedDate))) to dFormattedDate
Function_Return dFormattedDate
End_Function
Function FormatSystemTimeToTime tWinSystemTime SystemTime Returns Time
Integer iDataLength
WString wsFormattedTime wsLocaleName
tTimeZoneInformation TimeZoneInfo
Time tFormattedTime
Move "" to wsLocaleName
Move (CompileTimeGetTimeFormatEx (AddressOf (wsLocaleName), 0, AddressOf (SystemTime), 0, 0, 0)) to iDataLength
Move (ZeroString (iDataLength)) to wsFormattedTime
Move (CompileTimeGetTimeFormatEx (AddressOf (wsLocaleName), 0, AddressOf (SystemTime), 0, AddressOf (wsFormattedTime), iDataLength)) to iDataLength
Move (CString (wsFormattedTime)) to tFormattedTime
// This makes the time to be one hour higher than the actual time(!). Not sure why.
// Get TimeZoneInformation to TimeZoneInfo
Move (DateAddHour (tFormattedTime, TimeZoneInfo.DaylightDate.wHour)) to tFormattedTime
Function_Return tFormattedTime
End_Function
Function TimeZoneInformation Returns tTimeZoneInformation
tTimeZoneInformation TimeZoneInfo
Integer iRetval
Move (CompileTimeGetTimeZoneInformation (AddressOf (TimeZoneInfo))) to iRetval
Function_Return TimeZoneInfo
End_Function
Procedure ShowCompileTimeFileError Integer iErrorNumber String sAppendErrorText
Pointer lpOut
Integer iRetChars iRetVal
String sFilename sMessage
WString wsMsg
Move 0 to lpOut
Move (FormatMessageW((FORMAT_MESSAGE_FROM_SYSTEM+FORMAT_MESSAGE_IGNORE_INSERTS+FORMAT_MESSAGE_ALLOCATE_BUFFER), CreationNULL, iErrorNumber, CreationNULL, AddressOf(lpOut), 0, CreationNULL)) to iRetChars
If (iRetChars > 0) Begin
Move (ZeroString(iRetChars)) to wsMsg
Move (CopyMemory(AddressOf(wsMsg), lpOut, iRetChars * 2)) to iRetVal
Move (Free(lpOut)) to iRetVal
Move wsMsg to sMessage
If (num_arguments > 0) Begin
Move (Trim(sAppendErrorText)) to sAppendErrorText
If (sAppendErrorText <> "") Begin
Move (sMessage + "\n" + sAppendErrorText) to sMessage
End
End
Send Info_Box sMessage
End
End_Procedure
End_Class
// *** Main Interface Message ***
Function ProgramCompileDate Global String sFileName Returns DateTime
tWinFileTime CreationFileTime
String sCompileTime
Handle ho
DateTime dtFileTime
// From DataFlex 2025 there is a system function that returns the compiled date & time.
#IF (!@ > 240)
UBigInt ullUnixUTC
Move COMP$TIMESTAMP to ullUnixUTC
Move 1/1/1970 to dtFileTime
Move (DateAddSecond(dtFileTime, ullUnixUTC)) to dtFileTime
#ELSE
Get Create (RefClass(cFileCompileDateAndTime)) to ho
Get CreationFileCompilationTime of ho sFileName to dtFileTime
Send Destroy of ho
#ENDIF
Function_Return dtFileTime
End_Function