Declaring an External Function to the Compiler
Declare Function abGetSystemDirectory _
Lib "kernel32" _
Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) _
As Long
Sub WinSysDir()
Dim strBuffer As String
Dim intLength As Integer
Dim strDirectory As String
strBuffer = Space$(160)
intLength = abGetSystemDirectory(strBuffer, Len(strBuffer))
strDirectory = Left(strBuffer, intLength)
MsgBox strDirectory
End Sub
Related examples in the same category