GetWindowsDirectory

Version 3.0

Syntax

WORD GetWindowsDirectory(lpBuffer,nSize)

This function obtains the pathname of the Windows directory. The Windows directory contains such files as Windows applications, initialization files, and help files.

Parameter Type/Description  

lpBuffer LPSTR Points to the buffer that is to receive the null-terminated character string containing the pathname.  
nSize int Specifies the maximum size (in bytes) of the buffer. This value should be set to at least 144 to allow sufficient room in the buffer for the pathname.  

Return Value

The return value is the length of the string copied to lpBuffer, not including the terminating null character. If the return value is greater than nSize, the return value is the size of the buffer required to hold the pathname. The return value is zero if the function failed.

Comments

The pathname retrieved by this function does not end with a backslash (\), unless the Windows directory is the root directory. For example, if the Windows directory is named WINDOWS on drive C:, the pathname of the Windows directory retrieved by this function is C:\WINDOWS. If Windows was installed in the root directory of drive C:, the pathname retrieved by this function is C:\.