'Em um módulo:
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Function WinDir() As String
Dim Buffer As String * 256
GetWindowsDirectory Buffer, 256
WinDir = Left(Buffer, InStr(Buffer, Chr(0)) - 1)
End Function
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Function WinDir() As String
Dim Buffer As String * 256
GetWindowsDirectory Buffer, 256
WinDir = Left(Buffer, InStr(Buffer, Chr(0)) - 1)
End Function