Dec
19
把EXE文件加入资源文件,需要时还原成EXE文件的方法(实例)
雪糕先生 2009/12/19
13:24
13:24
把EXE加入到VB工程资源中,这是个不错的方法,下载是vb源代码:
引用
Private Const FILESIZEOFAPP = 154688 '我生成的APP.Exe大小是154688Byte
Private Sub Command1_Click() '单击按钮cmdOK运行代码
Dim APP() As Byte 'APP是个Btye类型和数组
Dim Counter As Long
APP = LoadResData(101, "CUSTOM") '将自定义资源中101号资源读入数组
'注意,资源标识为"CUSTOM"而非数字
If Dir(App.Path & "\APP.Exe") <> "" Then '第一次按command1有效
MsgBox App.Path & "\APP.Exe 已经存在!"
Exit Sub
End If
Open App.Path & "\APP.exe" For Binary As #1 '以二进制方式写入所在的目录
For Counter = 0 To FILESIZEOFAPP - 1 '注意因为从0 Byte开始因此以文件大小 - 1Byte 为终
Put #1, , APP(Counter)
Next Counter
Close #1
Shell App.Path & "\APP.Exe", vbNormalFocus '运行刚生成的APP.Exe
Unload Me
End Sub
Private Sub Command1_Click() '单击按钮cmdOK运行代码
Dim APP() As Byte 'APP是个Btye类型和数组
Dim Counter As Long
APP = LoadResData(101, "CUSTOM") '将自定义资源中101号资源读入数组
'注意,资源标识为"CUSTOM"而非数字
If Dir(App.Path & "\APP.Exe") <> "" Then '第一次按command1有效
MsgBox App.Path & "\APP.Exe 已经存在!"
Exit Sub
End If
Open App.Path & "\APP.exe" For Binary As #1 '以二进制方式写入所在的目录
For Counter = 0 To FILESIZEOFAPP - 1 '注意因为从0 Byte开始因此以文件大小 - 1Byte 为终
Put #1, , APP(Counter)
Next Counter
Close #1
Shell App.Path & "\APP.Exe", vbNormalFocus '运行刚生成的APP.Exe
Unload Me
End Sub
赞助商链接
分类
热门文章
- [21863]五种方法安装Windows...
- [5891]雪糕乐园小游戏集2.04版!...
- [5750]开机自动检测网络状态运行程序...
- [5424]双路由器上网的连接和设置方法
- [4732]Google提供的免费天气预...
- [4693]QQ临时会话(强制聊天)工具...
- [4623]EvaPhone - 无需注...
- [4608]ESET NOD32最新升级...
- [4487]WINDOWS 7 如何快速...
- [4038][原创]雪糕乐园-图片轮换屏...
VB判断当前显示分享辨率(实例)
登陆网站用户名密码-VB源码(实例)
