求教高手:有没有办法,将vb调用的dll作为资源插入到编译后的exe中,如何操作!

lanlansky 2002-09-14 12:01:18
如题,分不够可以加!

...全文
369 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
echos 2002-12-30
  • 打赏
  • 举报
回复
结贴呗,给分哦
lanlansky 2002-12-29
  • 打赏
  • 举报
回复
呵呵!以前的贴子忘了结
echos 2002-10-18
  • 打赏
  • 举报
回复
给分呗
echos 2002-10-18
  • 打赏
  • 举报
回复
给你一段代码,自己调整资源文件就可以了
Option Explicit
' 自动注册组件
Private Declare Function DLLSelfRegister Lib "VB6STKIT.DLL" (ByVal lpDllName As String) As Integer
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Const ERROR_SUCCESS = &H0
Private Const MAX_PATH = 260
Private Const OCXSIZE = 385024 '欲生成的控件大小是57344Byte,名字为swflash.ocx
Private strSysPath As String
Private strResOct As String

Public Function GetSystemDirectory_test() As String '获得文件路径
Dim s As String, Length As Long
'Dim tempthesyspath As String
s = String(MAX_PATH, 0)
Length = GetSystemDirectory(s, MAX_PATH)
s = Left(s, InStr(s, Chr(0)) - 1)
' MsgBox S, , "GetSystemDirectory"
'你要把组件释放的目录(我是把它放到了系统文件夹下的一个目录里面)
GetSystemDirectory_test = s & "\flashocx"

End Function

Private Sub resOut()'释放资源
Dim Ocx() As Byte 'OCX是个Btye类型的数组
Dim Counter As Long
Dim Fsys As Object

Ocx = LoadResData(101, "CUSTOM") '将自定义资源中101号资源读入数组OCX
'注意,微软的帮助中对加载自定义资源的说明有错误,自定义资源标识为"CUSTOM"而不是帮助所说的数字10

' If Right(App.Path, 1) = "\" Then '读取程序所在路径,判断是否为根目录并分别处理
'程序在根目录下

Set Fsys = CreateObject("Scripting.FileSystemObject")
If Not Fsys.FolderExists(strSysPath) Then Fsys.CreateFolder (strSysPath)
Set Fsys = Nothing
If Dir(GetSystemDirectory_test & "\swflash.ocx") = "" Then '程序路径下有无控件,无则生成控件
'以二进制方式写(生成)控件到主程序所在的目录
Open GetSystemDirectory_test & "\swflash.ocx" For Binary As #1
For Counter = 0 To OCXSIZE - 1 '注意因为从0 Byte开始因此以文件大小 - 1Byte 为终值
Put #1, , Ocx(Counter)
Next Counter
Close #1
End If

'程序不在根目录下
End Sub


Sub Main()
strSysPath = GetSystemDirectory_test
If Dir(strSysPath & "\swflash.ocx") = "" Then
'释放资源
resOut
End If
'注册控件
strResOct = DLLSelfRegister(strSysPath & "\swflash.ocx")
end sub

sob 2002-09-22
  • 打赏
  • 举报
回复
打一下包,将dll添加过去就行了
viperstorm 2002-09-21
  • 打赏
  • 举报
回复
no problem
lanlansky 2002-09-21
  • 打赏
  • 举报
回复
如果Dll很大,>1MB 这样可以么?
lanlansky 2002-09-21
  • 打赏
  • 举报
回复
MSDN :LoadResData 从资源文件装载的数据可以达到 64K。

to creakmud(剧情可乐) & viperstorm

何解?
creakmud 2002-09-15
  • 打赏
  • 举报
回复
有用的话记得给我加分哦:)初到贵地,还没有尝试过加分的感觉:)
creakmud 2002-09-15
  • 打赏
  • 举报
回复
给你一个思路:
第一步:建立资源文件,把你的dll加进去(一定要记住每个dll文件的大小,这是关键)
第二步:在编程过程中按正常方式引用DLL
第二步:
运行时,首先运行脱壳程序:
1、定义 bDll() as byte 数组(大小要和原Dll文件字节数一致)
2、用LoadResData函数读出并存放到 bDll()中
3、判断程序目录是否已经存在DLL文件,如果不存在则把bDll()内容以原dll文件名保存到程序目录中
脱壳完成,开始运行主程序


haoyipeng 2002-09-15
  • 打赏
  • 举报
回复
晕,还是没有解决!
WizardBear 2002-09-14
  • 打赏
  • 举报
回复
不用dll,vb直接就能使用资源加入编译的exe中,

在Add-InManager中,有一个vb6 resource editor,

选中它就可以编辑rc文件到vb工程里面,

支持的资源类型同vc
Iamfish 2002-09-14
  • 打赏
  • 举报
回复
@_@
lanlansky 2002-09-14
  • 打赏
  • 举报
回复
to WizardBear(飞猫_SP6 :所答非所问
将vb调用的dll
作为资源插入到
编译后的exe中,
如何操作???

1,066

社区成员

发帖
与我相关
我的任务
社区描述
VB 资源
社区管理员
  • 资源
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧