?? code277a.txt
字號:
Option Explicit
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
Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Public Function StripTerminator(ByVal strString As String) As String
Dim intZeroPos As Integer
intZeroPos = InStr(strString, Chr$(0))
If intZeroPos > 0 Then
StripTerminator = Left$(strString, intZeroPos - 1)
Else
StripTerminator = strString
End If
End Function
Public Function GetTempName() As String
Dim ReturnVal As Long, PathBuffSize As Long, PathBuff As String
Dim Prefix As String, FileName As String
PathBuffSize = 255
PathBuff = Space$(PathBuffSize)
Prefix = "tmp"
FileName = Space$(255)
ReturnVal = GetTempPath(PathBuffSize, PathBuff)
If ReturnVal = 0 Then
MsgBox "Error getting directory"
Exit Function
End If
PathBuff = StripTerminator(PathBuff)
ReturnVal = GetTempFileName(PathBuff, Prefix, 0&, FileName)
If ReturnVal = 0 Then
MsgBox "Error getting file."
Else
GetTempName = StripTerminator(FileName)
End If
End Function
Public Sub Main()
Dim FileName As String
FileName = GetTempName()
If FileName <> "" Then
Open FileName For Output As #1
Print #1, "Created a temp file!", FileName
Close #1
Debug.Print FileName
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -