PDA

Click to See Complete Forum and Search --> : calling a function from activeX dll


gabriste
May 13th, 2002, 01:28 PM
Is it possible to access a function in an axtiveX dll without including the source code in the project? I know I can call a function from other dlls i.e. :

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

from then on you can just call GetCursorPos from your app, but this is a windows type dll... can the same be done with a vb activeX dll?

I know I can include the source code, and declair a new whatever to call the function, but I am trying to create a dll I can give to other programers to use so they can't (easily) get my source code, but they can still use my functions...

anyone ever done this? when I try something like:

Declare Function MyFunction Lib "mydll.dll"

I get an error: "Run Time Error 453: Cannot find entry point MyFunction in "mydll.dll"

anyone knwo what I may be doing wrong?

thanks in advance...

ChiefRB
May 13th, 2002, 02:27 PM
Because VB DLLs aren't *true* DLLs in the sense that the Windows API and other C or C++ DLLs are, you can't use the
Private Declare Function...
syntax to use it.

Because they are ActiveX COM DLLs, they contain classes. In order to use the functions, you must create an instance of the class - an object.
You can use the DLLs without the source code, like this:

Compile your ActiveX DLL. Open a new Standard EXE VB project, and click on Project-->References... Find your ActiveXDLL name in the list, and check it.
Then, in code, you can create objects like this:
Dim Obj As ActiveXDLLName.ClassName
Set Obj = New ClassName
All you have to do is replace ActiveXDLLName with the name of your DLL, and ClassName with the name of the class within the DLL.

Edneeis
May 13th, 2002, 03:52 PM
If you really don't want them to have to declare objects in order to use a function you can use GlobalMultiUse instancing on the classes and then the functions can be reached as if they were intrinsic (after making the refernce of course).