Dec
19
把EXE文件加入资源文件,需要时还原成EXE文件的方法(实例)
雪糕先生 2009/12/19 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
分类
热门文章
- [46488]五种方法安装Windows...
- [31118]您可能需要与该网络的 in...
- [15799]2012东埔英歌舞
- [15076]开机自动检测网络状态运行程...
- [14528]APMServ一键快速搭建...
- [13753]各种BIOS的设置细解
- [13519]EvaPhone - 无需...
- [13419]Google提供的免费天气...
- [13118]双路由器上网的连接和设置方...
- [12618]雪糕乐园小游戏集2.04版...