Click to Rate and Give Feedback
MSDN
MSDN Library
System Services
System Information
 GetSystemDirectory Function
GetSystemDirectory Function

Retrieves the path of the system directory. The system directory contains system files such as dynamic-link libraries and drivers.

This function is provided primarily for compatibility. Applications should store code in the Program Files folder and persistent data in the Application Data folder in the user's profile. For more information, see ShGetFolderPath.

Syntax

C++
UINT WINAPI GetSystemDirectory(
  __out  LPTSTR lpBuffer,
  __in   UINT uSize
);

Parameters

lpBuffer [out]

A pointer to the buffer to receive the path. This path does not end with a backslash unless the system directory is the root directory. For example, if the system directory is named Windows\System on drive C, the path of the system directory retrieved by this function is C:\Windows\System.

uSize [in]

The maximum size of the buffer, in TCHARs.

Return Value

If the function succeeds, the return value is the length, in TCHARs, of the string copied to the buffer, not including the terminating null character. If the length is greater than the size of the buffer, the return value is the size of the buffer required to hold the path, including the terminating null character.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

Applications should not create files in the system directory. If the user is running a shared version of the operating system, the application does not have write access to the system directory.

Examples

For an example, see Getting System Information.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Winbase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

Unicode and ANSI names

GetSystemDirectoryW (Unicode) and GetSystemDirectoryA (ANSI)

See Also

GetCurrentDirectory
GetWindowsDirectory
SetCurrentDirectory
System Information Functions

 

 

Send comments about this topic to Microsoft

Build date: 2/4/2010

Community Content   What is Community Content?
Add new content RSS  Annotations
vb.net syntax      dmex   |   Edit   |   Show History
<DllImport("kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Public Shared Function GetSystemDirectory(ByVal sb As StringBuilder, ByVal length As Integer) As Integer
End Function
Flag as ContentBug
C# syntax      dmex   |   Edit   |   Show History
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int GetSystemDirectory(StringBuilder sb, int length);
Tags What's this?: c# (x) syntax (x) Add a tag
Flag as ContentBug
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker