'-----------------------------------
'取得临时文件名
'-----------------------------------
Private Function TemporaryFile(Optional FilePrefix As String) As String
    Dim lngReturn As Long
    Dim strTempFile As String
    Dim strWindowsTempDir As String
    
    Const MAX_PATH = 260
    
    strWindowsTempDir = Space(MAX_PATH)
    lngReturn = GetTempPath(MAX_PATH, strWindowsTempDir)
    strWindowsTempDir = Left(strWindowsTempDir, lngReturn)
    strTempFile = Space(MAX_PATH)
    If FilePrefix = "" Then
        FilePrefix = "TMP"
    End If
    lngReturn = GetTempFileName(strWindowsTempDir, FilePrefix, 0, strTempFile)
    If lngReturn <> 0 Then
        strTempFile = Left(strTempFile, InStr(strTempFile, Chr(0)) - 1)
        TemporaryFile = strTempFile
    End If
End Function