CodeItBetter Programming Another VB Programming Blog

How to get Temp Path

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'System & API - How to get Temp Path
Option Explicit
 
Private Declare Function PathAddBackslash Lib "shlwapi.dll" Alias "PathAddBackslashA" _
    (ByVal pszPath As String) As Long
Private Declare Function GetTempPathA Lib "kernel32" (ByVal nBufferLength As Long, _
    ByVal lpBuffer As String) As Long
 
Public Function GetTempPath() As String
    Dim s As String
    Dim I As Integer
    I = GetTempPathA(0, "")
    s = Space(I)
    Call GetTempPathA(I, s)
    GetTempPath = AddBackslashUsingAPI(Left$(s, I - 1))
End Function
 
Public Function AddBackslashUsingAPI(ByVal sFolder As String) As String
    sFolder = sFolder & String(1, 0)
    PathAddBackslash sFolder
    AddBackslashUsingAPI = sFolder
End Function
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.