用GetSystemDirectory api函数 UINT GetSystemDirectory( LPTSTR lpBuffer, // address of buffer for system directory UINT uSize // size of directory buffer );
1) Dim sSave As String, Ret As Long 'Create a buffer sSave = Space(255) 'Get the system directory Ret = GetSystemDirectory(sSave, 255) 'Remove all unnecessary chr$(0)'s sSave = Left$(sSave, Ret) 'Show the windows directory MsgBox "Windows System directory: " + sSave2) Private Declare Function GetWindowsDirectory lib "kernel32" Alias "GetWindowsDirectoryA" ( ByVal lpBuffer As String, ByVal nSize As Long) As Long Dim Temp As String * 256 dim WinDir as string X = GetWindowsDirectory(Temp, Len(Temp)) WinDir = Left$(Temp, X) msgbox windir
UINT GetSystemDirectory(
LPTSTR lpBuffer, // address of buffer for system directory
UINT uSize // size of directory buffer
);
Dim sSave As String, Ret As Long
'Create a buffer
sSave = Space(255)
'Get the system directory
Ret = GetSystemDirectory(sSave, 255)
'Remove all unnecessary chr$(0)'s
sSave = Left$(sSave, Ret)
'Show the windows directory
MsgBox "Windows System directory: " + sSave2)
Private Declare Function GetWindowsDirectory lib "kernel32" Alias "GetWindowsDirectoryA" ( ByVal lpBuffer As String, ByVal nSize As Long) As Long
Dim Temp As String * 256
dim WinDir as string
X = GetWindowsDirectory(Temp, Len(Temp))
WinDir = Left$(Temp, X)
msgbox windir