GetSystemDirectory Function

Declare Function GetSystemDirectory Lib "kernel32.dll" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

GetSystemDirectory reads the path of Windows's System directory. This is where many important files for Windows are stored, including the API DLLs! Never assume this is "C:\Windows\System" because the Windows directory doesn't have to be called Windows! The path of the system directory is put into the string variable passed as lpBuffer. The function returns th length of the string, or 0 if it failed.

lpBuffer
A fixed-length string which will receive the path.
nSize
The length in characters of lpBuffer.

Example:

' Get the system directory
Dim buffer As String * 255
x = GetSystemDirectory(buffer, 255)
Debug.Print Left(buffer, x)  ' Could be C:\Windows\System

Related Call: GetWindowsDirectory
Category: System Information
Back to the index.


Back to Paul Kuliniewicz's Home Page
E-mail: Borg953@aol.com
This page is at http://members.aol.com/Borg953/api/functions/getsystemdirectory.html