From my understanding, that path will be a single-letter (the driver), followed by "\WINDOWS\SYSTEM32
" so that MAX_PATH
is more than enough to hold that path filled by GetSystemDirectory(). So it's safe to do:
TCHAR dir[MAX_PATH] = {0};
if(GetSystemDirectory(dir, sizeof(dir) / sizeof(*dir)) == 0) {
// check for GetLastError()
}
Or am I missing something?
The documentation provided for the recommended alternative to GetSystemDirectory
(which is ShGetFolderPath
) says the following about its pszPath
parameter:
A pointer to a null-terminated string of length MAX_PATH which will receive the path. If an error occurs or S_FALSE is returned, this string will be empty. The returned path does not include a trailing backslash. For example, "C:\Users" is returned rather than "C:\Users\".
So, yes, MAX_PATH
will be a big enough buffer size.