JackKaptijn
Registered User.
- Local time
- Today, 07:53
- Joined
- Dec 10, 2012
- Messages
- 38
Hello,
I am using a API to generate a random / unique directory.
This an API form a 32-bits environment.
I know that you can still use it when declaring it with PtrSafe
But does anybody has got a better alternative in 64-bits?
This is the code I am using:
I am using a API to generate a random / unique directory.
This an API form a 32-bits environment.
I know that you can still use it when declaring it with PtrSafe
But does anybody has got a better alternative in 64-bits?
This is the code I am using:
Code:
Option Compare Database
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Declare Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, ByVal lpTempFileName As String) As Long
Function GetTempFolder() As String
Const MAX_PATH As Long = 260
Dim strTempfolder As String
Dim lngReturn As Long
strTempfolder = String(MAX_PATH, Chr$(0))
lngReturn = GetTempPath(MAX_PATH, strTempfolder)
If lngReturn <> 0 Then
lngReturn = GetTempFileName(Replace(strTempfolder, Chr$(0), ""), "Tmp", 0, strTempfolder)
GetTempFolder = Replace(Replace(strTempfolder, Chr$(0), "") & "\", ".tmp", "")
Else
GetTempFolder = vbNullString
End If
End Function