GetWindowsDir

3.1

  #include <ver.h>    

  UINT GetWindowsDir(lpszAppDir, lpszPath, cbPath)    
  LPCSTR lpszAppDir; /* address of Windows directory */
  LPSTR lpszPath; /* address of buffer for path */
  int cbPath; /* size of buffer for path */

The GetWindowsDir function retrieves the path of the Windows directory. This directory contains such files as Windows applications, initialization files, and help files.

GetWindowsDir is used by MS-DOS applications that set up Windows applications; it exists only in the static-link version of the File Installation library. Windows applications should use the GetWindowsDirectory function to determine the Windows directory.

Parameters

lpszAppDir

Specifies the current directory in a search for Windows files. If the Windows directory is not on the path, the application must prompt the user for its location and pass that string to the GetWindowsDir function in the lpszAppDir parameter.

lpszPath

Points to the buffer that will receive the null-terminated string containing the path.

cbPath

Specifies the size, in bytes, of the buffer pointed to by the lpszPath parameter.

Return Value

The return value is the length of the string copied to the lpszPath parameter, including the terminating null character, if the function is successful. If the return value is greater than the cbPath parameter, it is the size of the buffer required to hold the path. The return value is zero if the function fails.

Comments

The path that this function retrieves does not end with a backslash unless the
Windows directory is the root directory. For example, if the Windows direc-tory is named WINDOWS on drive C, the path retrieved by this function is C:\WINDOWS. If Windows is installed in the root directory of drive C, the path retrieved is C:\.

After the GetWindowsDir function locates the Windows directory, it caches the location for use by subsequent calls to the function.

See Also

GetSystemDir, GetWindowsDirectory