Article ID: 108278
Article Last Modified on 6/11/2007
'The following two declare statements need to be entered each on a single
'line in the module sheet.
Declare Function GetSystemDirectory Lib "kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As _
String, ByVal nSize As Long) As Long
Declare Function GetWindowsDirectory Lib "kernel32" Alias _
"GetWindowsDirectoryA" (ByVal lpBuffer As _
String, ByVal nSize As Long) As Long
Sub Get_Windows_Directory()
'sets the buffer length for both variables to 144
Dim Win_Dir As String * 144
Dim Sys_Dir As String * 144
y = GetWindowsDirectory(Win_Dir, 144)
'returns the \Windows directory
wd = Left(Win_Dir, y)
'Displays the windows directory in a Message box
MsgBox wd
'Returns the Windows\System directory
x = GetSystemDirectory(Sys_Dir, 144)
sd = Left(Sys_Dir, x)
'Displays the \Windows\System directory in a Message box
MsgBox sd
End Sub
'The following two declare statements need to be entered each on a single
'line in the module sheet.
Declare Function GetSystemDirectory Lib "KERNEL" (ByVal lpBuffer As _
String, ByVal nSize As Integer) As Integer
Declare Function GetWindowsDirectory Lib "KERNEL" (ByVal lpBuffer As _
String, ByVal nSize As Integer) As Integer
Sub GetDir()
'sets the buffer length for both variables to 144
Dim Win_Dir As String * 144
Dim Sys_Dir As String * 144
'returns the \Windows directory
y = GetWindowsDirectory(Win_Dir, Len(Win_Dir))
'Displays the windows directory in a Message box
MsgBox Win_Dir
'Returns the Windows\System directory
x = GetSystemDirectory(Sys_Dir, Len(Win_Dir))
'Displays the \Windows\System directory in a Message box
MsgBox Sys_Dir
End Sub
Additional query words: 8.00 97 XL97 API XL
Keywords: kbprogramming KB108278