lzn3303768 发表于 2008-5-24 22:15

[转贴]动态加载dll

我们都知道VB加载dll可以通过vb中引用来实现,可是需要动态引用呢?我通过摸索发现可以先regsvr32那个dll,然后在vb中createobject(dll插件为vb编译,若为标准dll,loadlibrary即可)。 详细代码如下[code]
Dim t As String
Open "list.txt" For Input As #1
Open "reg.bat" For Output As #2
Do Until EOF(1)
Input #1, t
Print #2, "regsvr32 " & t & " /s" '注册控件
t = Replace(t, ".dll", "")
List1.AddItem t
Loop
Close
Close
Shell ("reg.bat")



'使用部分
Dim a As Object
Dim b As String
b = List1.Text & "startclass"
Set a = CreateObject(List1.Text & "." & b) ‘工程名 + . +类名
a.run[/code]原帖地址:[url]http://www.5ixbc.net/post.php?action=edit&fid=12&tid=456&pid=763&page=1&extra=page%3D1[/url]

三断笛 发表于 2008-5-24 22:33

CreateObject效率比较低 MSDN上说的

lzn3303768 发表于 2008-5-25 09:12

关键是动态的,要不才不用createobject呢

flyue 发表于 2008-5-25 14:40

要是用户的电脑里没有regsvr32.exe或regsvr32.exe被病毒感染了那怎么办?

multiple1902 发表于 2008-5-25 18:55

[quote][bo][un]flyue[/un] 在 2008-5-25 14:40 的发言:[/bo]

要是用户的电脑里没有regsvr32.exe或regsvr32.exe被病毒感染了那怎么办? [/quote]
一般不考虑吧

lzn3303768 发表于 2008-5-25 21:18

回复 4# flyue 的帖子

程序自己内置一个,运行时释放出来

multiple1902 发表于 2008-5-25 21:31

[quote][bo][un]lzn3303768[/un] 在 2008-5-25 21:18 的发言:[/bo]

程序自己内置一个,运行时释放出来 [/quote]
好主意!

lzn3303768 发表于 2008-5-25 21:46

用二进制存贮到时候释放(不可用字符,用字符的不能运行)

页: [1]

编程论坛