Declare Function GetTempPath Lib "kernel32" Alias _
"GetTempPathA" (ByVal nBufferLength As Long, _ ByVal lpBuffer As String) As Long Public Const MAX_PATH = 260 Public Function GetTmpPath() Dim strFolder As String Dim lngResult As Long strFolder = String(MAX_PATH, 0) lngResult = GetTempPath(MAX_PATH, strFolder) If lngResult <> 0 Then GetTmpPath = Left(strFolder, InStr(strFolder, Chr(0)) - 1) Else GetTmpPath = "" End If End Function 'Un esempio di come usare la funzione: Call MsgBox("Il percorso temporaneo e' " & GetTmpPath, _ vbInformation Se tu hai un progetto che produce file temporanei a run-time, e' una buona pratica per creare questi file nella directory temporanea di Windows. Questa directory e' usualmenate "c:\windows\temp", sebbene essa puo' variare con differenti configurazioni di Windows. E possibile recuperare il percorso della directory temporanea usando il seguente codice. |