Declare Function GetTempPath Lib "KERNEL32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Public Function GetWindowTempPath() As String
Dim Dummy As Long, StrLen As Long, TempPath As String
StrLen = 255
TempPath = String$(StrLen, 0)
Dummy = GetTempPath(StrLen, TempPath)
If Dummy Then
GetWindowTempPath = Left$(TempPath, Dummy)
Else
GetWindowTempPath = ""
End If
End Function
获得Windows目录:
Declare Function GetWindowsDirectory Lib "KERNEL32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Public Function GetWindowsPath() As String
Dim Dummy As Long, StrLen As Long, TempPath As String
StrLen = 255
TempPath = String$(StrLen, 0)
Dummy = GetWindowsDirectory(TempPath, StrLen)
If Dummy Then
GetWindowsPath = Left$(TempPath, Dummy)
Else
GetWindowsPath = ""
End If
End Function