Article ID: 137034
Article Last Modified on 12/9/2003
Declare Function GetTempFileName Lib "Kernel" (ByVal cDriveLetter as _
Integer, ByVal lpPrefixString As String, ByVal wUnique As Integer, _
ByVal lpTempFileName As String) As Integer
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
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
Private Sub Form_Click()
Dim lpszPath As String
Dim lpPrefixString As String
Dim wUnique As Long
Dim lpTempFileName As String
' Because the C:\windows directory, probably, doesn't exist,
' using this line will cause the problem to occur:
lpszPath = "C:\windows" ' Line A
' To resolve the problem, change the previous line into a comment
' and change the following line from a comment into an executed line:
' lpszPath = "C:\windows" ' Line B
lpPrefixString = "shn"
' If wUnique is nonzero, it will be appended
' to the temporary filename. If the parameter is zero,
' Windows uses the current system time to create a
' number to append to the filename.
wUnique = 0
' Initialize variable
lpTempFileName = Space$(100)
Print GetTempFileName(lpszPath, lpPrefixString,_
wUnique, lpTempFileName)
' If running under Windows 95 or Windows 98, use the following line
' to get rid of the null character
' Print Mid$(lpTempFileName, 1, InStr(lpTempFileName, Chr$(0)) - 1)
Print lpTempFileName
End Sub
Additional query words: kbdsd
Keywords: kbapi kbprb KB137034