Results 1 to 3 of 3

Thread: calling a function from activeX dll

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    1

    calling a function from activeX dll

    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...

  2. #2
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    uk
    Posts
    327
    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:
    Code:
    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.

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width