borderAndreaVB free resources for Visual Basic developersborder

AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2013 Andrea Tincani
:: 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

:: Navigation

Home

Files and Disks Tips

Previous Tip

Next Tip

:: Search this site
Google
:: Related Topics
icon 28-07-2010 Re: Problem with IE7 by dvdv882
icon 30-08-2006 Re: How to Create Demo Version by JLRodgers
icon 17-10-2004 Re: ssfPERSONAL in WinXP by VBer
icon 13-04-2004 Getting Hardware Info by Shady
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2013 Andrea Tincaniborder