Click to See Complete Forum and Search --> : Add reference to DLL in runtime


January 17th, 2000, 12:17 PM
I have to add reference to a dll in run time as and when required..
How can i do it??
I have tried with Declare/Call method as for other dll files in the system directory of windows.
but for other DLLs ( created by me) it gives error like
"Error during load"!!

Does anyone have any idea if something like plugins be implemented in VB

Chris Eastwood
January 18th, 2000, 03:54 AM
You can create a kind of plugin in VB where you use ActiveX DLL's that export an interface that your program knows about (it might even be the program exporting it). You can then simply get the PROGID of the ActiveX control from somewhere (eg. get myProject.myClass (implements 'myinterface') from an inifile or database), then do a :


'
Dim oObject as myInterface
'
set oObject = CreateObject("myProject.myClass")
'
Call oObject.Initialise (with, some, parameters)
oObject.DoSomething (with, some, other, parameters)
Call oObject.Terminate
'
set oObject = nothing




It is possible to load standard DLL's using LoadLibrary in vb, but you can't call any of the routines contained within them in this way.


Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb

Lothar Haensler
January 18th, 2000, 07:03 AM
>It is possible to load standard DLL's using LoadLibrary in vb, but you can't call any of the routines contained within them in this way.

...unless you use the Call32.DLL that was published a few years ago on VBPJ. This DLL would allow you to dynamically declare DLL functions (including parameters) and call these functions with parameters via an entry point in the DLL.

Chris Eastwood
January 18th, 2000, 08:16 AM
Sounds Good!

Any idea what the issue was ?

Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb

Lothar Haensler
January 18th, 2000, 08:37 AM
>Any idea what the issue was ?
unfortunately not.
But, I found the call32.dll in our network and I remember having tested it.
OTOH, I might even be wrong and the DLL is only for 16 bit apps calling 32 bit DLLs?