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.
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.