-
Notifications
You must be signed in to change notification settings - Fork 72
/
GetSystemDateFormat.ahk
52 lines (38 loc) · 1.04 KB
/
GetSystemDateFormat.ahk
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
; https://autohotkey.com/board/topic/66811-way-to-get-short-date-format-used-by-local-machine/
GetSystemDateFormat()
{
; return the system short date format e.g. dd-MMM-yyyy
; MsgBox params: %params%
; declare local, global, static variables
Try
{
; set default return value
; ReturnValue := 0
DateFormat := ""
; validate parameters
; If !Condition
; Throw, Exception("xErrorMessagex")
; initialise variables
; get system date format
LOCALE_SYSTEM_DEFAULT := 0x0800
LOCALE_USER_DEFAULT := 0x0400
LOCALE_SSHORTDATE := 0x1F
VarSetCapacity(DateFormat,80)
DllCall("GetLocaleInfo","uint",LOCALE_USER_DEFAULT,"uint",LOCALE_SSHORTDATE,"str",DateFormat,"uint",80)
}
Catch, ThrownValue
{
; ReturnValue := !ReturnValue
CatchHandler(A_ThisFunc,ThrownValue.Message,ThrownValue.What,ThrownValue.Extra,ThrownValue.File,ThrownValue.Line,0,0,0)
}
Finally
{
}
; return
; Return ReturnValue
Return DateFormat
}
/* ; testing
ReturnValue := GetSystemDateFormat()
MsgBox, GetSystemDateFormat`n`nReturnValue: %ReturnValue%
*/