Declaring an External Function to the Compiler : Windows API « Windows API « VBA / Excel / Access / Word






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

1.Use 32-bit API declaration
2.Using a Function in a DLL
3.Playing .Wav files via the Windows API
4.Waiting for an application to end