/
GetSystemDirectory.ahk
31 lines (25 loc) · 1.56 KB
/
GetSystemDirectory.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
; ===============================================================================================================================
; Function......: GetSystemDirectory
; DLL...........: Kernel32.dll
; Library.......: Kernel32.lib
; U/ANSI........: GetSystemDirectoryW (Unicode) and GetSystemDirectoryA (ANSI)
; Author........: jNizM
; Modified......:
; Links.........: https://msdn.microsoft.com/en-us/library/ms724373.aspx
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724373.aspx
; ===============================================================================================================================
GetSystemDirectory()
{
static size := VarSetCapacity(buf, 260, 0)
if !(DllCall("kernel32.dll\GetSystemDirectory", "Ptr", &buf, "UInt", size))
return DllCall("kernel32.dll\GetLastError")
return StrGet(&buf, size, "UTF-16")
}
; ===============================================================================================================================
MsgBox % GetSystemDirectory()
/* C++ ==========================================================================================================================
UINT WINAPI GetSystemDirectory( // UInt
_Out_ LPTSTR lpBuffer, // Ptr (Str)
_In_ UINT uSize // UInt
);
============================================================================================================================== */