注册 登录
编程论坛 VB6论坛

求助各路 大神?我是新手。想问下VB怎么一关闭q1.exe 就删除q1.exe,不是删除主程序~~麻烦大师给修改下·谢谢了。

WSZXD 发布于 2020-01-04 23:00, 2293 次点击
想问下VB怎么一关闭q1.exe 就删除q1.exe,不是删除主程序~~麻烦大师给修改下·谢谢了。

麻烦各位大神给修改下 谢谢了也可以在这里下载http://zhangxiaoduan. 上传修改好的谢谢了。

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 Form_Unload(Cancel As Integer)
Kill App.Path & "\q1.exe"
End Sub

Private Sub Label1_Click()

End Sub

[此贴子已经被作者于2020-1-4 23:01编辑过]

3 回复
#2
tangjiashier2020-02-03 12:03
你可以用一个时钟控件去检测有没有q1这个进程,没有的时候删除q1。
#3
tanting3232020-02-05 21:24
学习下
#4
风吹过b2020-02-06 21:16
q1.exe
如果是你写的,
调用时,把自己的 进程ID 转递进去,
然后Q1.exe 每隔多少毫秒,发一个心跳包。如果有指定的时间之内没收到心跳包,启动循环删Q1.exe

如果不是你写的。
不怕报错,那就直接循环删Q1.exe

on error resume next
do while dir(App.Path & "\q1.exe")<>""
Kill App.Path & "\q1.exe"
loop

1