Article ID: 141803
Article Last Modified on 1/19/2007
'**********************************
'Declarations section of the module
'**********************************
Option Compare Database
Option Explicit
Declare Function apiGetWindowsDirectory& Lib "kernel32" Alias _
"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal _
nSize As Long)
Declare Function apiGetSystemDirectory Lib "kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize _
As Long) As Long
' This function returns the path to the Windows directory as a
' string.
Function GetWinDir () As String
Dim lpbuffer As String * 255
Dim Length as Long
Length = apiGetWindowsDirectory(lpbuffer, Len(lpbuffer))
GetWinDir = Left(lpbuffer, Length)
End Function
' This function returns the path to the Windows System directory
' as a string.
Function GetSysDir () As String
Dim lpbuffer As String * 255
Dim Length as Long
Length = apiGetSystemDirectory(lpbuffer, Len(lpbuffer))
GetSysDir = Left(lpbuffer, Length)
End Function
? GetWinDir()
? GetSysDir()
Keywords: kbhowto kbprogramming KB141803