| :: How to Get the Windows Temporary Directory |
Author |
David Costelloe |
Language |
VB5, VB6 |
Operating
Systems |
Windows 95, 98 and NT |
| API
Declarations |
' API
Private Declare Function GetTempPath Lib "kernel32.dll" Alias "GetTempPathA"
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long |
| Module |
Public Function GetTempDir() As String
' Returns the temp directory
from the OS system
Dim sBuffer As String
Dim HoldBuffer As String
Dim iBuffLen As Long
Dim iReturn As Long
Const BUFFER_LENGTH = 256
iBuffLen = BUFFER_LENGTH
sBuffer = Space(BUFFER_LENGTH)
iReturn = GetTempPath(iBuffLen, sBuffer) '* get rid of the null character
HoldBuffer = Left$(sBuffer, iBuffLen - 1)
GetTempDir = Left$(HoldBuffer, InStr(HoldBuffer, vbNullChar) - 1)
End Function |
| Usage |
'Usage:
Private Sub Command1_Click()
MsgBox GetTempDir
End Sub |
|
 |
|
 |