This tip demonstrates how to go
about finding the path to the Windows
System directory.
Declarations
You must copy this code into the
declarations section of the project.
Public Const MAX_PATH = 260
Declare Function GetSystemDirectory Lib
"kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As
String, ByVal _
nSize As Long) As Long
Code
Public Function GetSystemPath()
Dim strFolder As String
Dim lngResult As Long
strFolder = String(MAX_PATH, 0)
lngResult = GetSystemDirectory(strFolder, MAX_PATH)
If lngResult <> 0 Then
GetSystemPath = Left(strFolder,
InStr(strFolder, _
Chr(0)) - 1)
Else
GetSystemPath = ""
End If
End Function
Use
An
example of how to use this function:
Call MsgBox("The Windows System directory is
" & _
GetSystemPath, vbInformation)
|