Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Function GetTempDirectory() As String
Dim sBuffer As String
sBuffer = String$(260, vbNullChar)
If GetTempPath(Len(sBuffer), sBuffer) Then
' enlève les NULL
GetTempDirectory = LeftB$(sBuffer, InStrB(1, sBuffer, vbNullChar))
Else
GetTempDirectory = Environ$("TEMP")
End If
' ajoute le slash
If Not (RightB$(GetTempDirectory, 2) = "\") Then GetTempDirectory = GetTempDirectory & "\"
End Function