注册 登录
编程论坛 VB6论坛

想问下VB怎么一关闭q1.exe 就删除q1.exe,不是删除主程序~

WSZXD 发布于 2018-03-26 15:13, 2873 次点击
求助各路 大神?我是新手。
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
~麻烦大师给修改下·谢谢了。
想问下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:08编辑过]

8 回复
#2
Artless2018-03-26 20:34
没看懂
#3
WSZXD2018-03-27 11:12
回复 2楼 Artless
VB自释码放运行源码
#4
wds12018-03-27 11:34
如果只是实现自释放文件包含源码,那你用rar,把源码压缩为自释放文件就行了。

#5
WSZXD2018-03-27 12:30
回复 4楼 wds1
怎么写 给个源码
#6
风吹过b2018-03-27 15:38
估计第一件事,就是被杀软件干掉。

使用资源文件 。
      FileByte() = LoadResData(101, "CUSTOM")

判断文件是否存在,是,删除
以二进制打开文件
一次性把 整个数组写进去
关闭文件

没有循环,只有一个判断,再加三条 顺序语句。自己翻译为 代码。

#7
WSZXD2018-03-28 09:12
回复 6楼 风吹过b
给个参考源码 刚刚学习VB
#8
风吹过b2018-03-28 09:53
'判断文件是否存在,是,删除
if dir(sName) <> "" then
  kill sName
end if
'以二进制打开文件
Open sName For Binary As #1
'一次性把 整个数组写进去
Put #1,,FileByte
'关闭文件
Close #1
#9
WSZXD2020-01-04 23:11
回复 6楼 风吹过b
求助版主大神我是想问下VB怎么一关闭q1.exe 就删除q1.exe,不是删除主程序~~麻烦大师给修改下·谢谢了。
想问下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
1