我想问下·这是一个文件的释放·那么二个怎么写
我想问下·这是一个文件的释放·那么二个怎么写Public Function ExtractFile(ResIndex As Integer, ResType As String)
Dim TempFile() As Byte
Dim FileHandle As Integer '定义文件句柄
FileHandle = FreeFile '初始化文件句柄
TempFile = LoadResData(ResIndex, ResType) '装载资源文件
Open App.Path & "\q1.exe" For Binary Access Write As #FileHandle '以二进制方式操作文件
Put #FileHandle, , TempFile '写入文件
Close #FileHandle '关闭文件句柄
End Function
Private Sub cmdRes_Click()
Dim n As Integer
n = 0
n = ExtractFile(101, "CUSTOM") '
Shell App.Path & "\q1.exe", vbNormalFocus
If (n <> 0) Then
MsgBox "释放文件失败"
End If
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
Kill "q1.exe"
End Sub
在写一遍吗
Public Function ExtractFile(ResIndex As Integer, ResType As String)
Dim TempFile() As Byte
Dim FileHandle As Integer '定义文件句柄
FileHandle = FreeFile '初始化文件句柄
TempFile = LoadResData(ResIndex, ResType) '装载资源文件
Open App.Path & "\q1.exe" For Binary Access Write As #FileHandle '以二进制方式操作文件
Put #FileHandle, , TempFile '写入文件
Close #FileHandle '关闭文件句柄
End Function
Private Sub cmdRes_Click()
Dim n As Integer
n = 0
n = ExtractFile(101, "CUSTOM") '
Shell App.Path & "\q1.exe", vbNormalFocus
If (n <> 0) Then
MsgBox "释放文件失败"
End If
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
Kill "q1.exe"
End Sub