Results 1 to 8 of 8

Thread: Referencing a DLL programatically

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Posts
    4

    Referencing a DLL programatically

    Is this possible? I've been messing around with this for a bit, but haven't been able to successfully do this.

    I have an Active-X DLL called "Rodac.dll". with a class called clsDateEntry, containing a function called UserSelectedDate (with several string variables).

    I've successfully gotten it working by referencing the DLL, but I would prefer to remove this necessity.

    The following is the code I've tried:

    Declare Function UserSelectedDate Lib "C:\Rodac.dll" (ByVal strIncuType As String, ByVal strDate As String, ByVal strIncuNumber As String) As Integer

    To call the function:

    DateReturn = UserSelectedDate(strIncuType, strDate, strIncuNumber)



    Any options? I would also eventually like to move the Declare outside the general statements area, as the actual path to the dll will change.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    dim myobj as Object

    set myobj = CreateObject("dllname.classname")

    myobj is now your referenced object to your dll
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Posts
    4
    Originally posted by Cander
    dim myobj as Object

    set myobj = CreateObject("dllname.classname")

    myobj is now your referenced object to your dll
    I think I misphrased my question.

    I'm not looking to dynamically assign a variable to an already referenced DLL.

    I'm looking to reference out to an unreferenced DLL.

    (ie, just put myDll.dll on the drive, and reference the location in code without having to register it)

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    "I'm looking to reference out to an unreferenced DLL."

    No you phrased it correctly. That is exaclty what the code I gave you does.

    "(ie, just put myDll.dll on the drive, and reference the location in code without having to register it)"

    You CANNOT use an ActiveX DLL without registering. There is NO workaround for that.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    About as close as you get to not having to register the dll is registering it via code but then you have to have the path. The easiest way is just to shell regsrv32 with the path to the dll. But other than that Cander is right there is no way to avoid registering the dll.

    The Declare style you mentioned is for non COM dlls, which VB can't make. Also using Cander's code you don't need to have the dll referenced, just registered.

  6. #6
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    there is no way to avoid registering the dll
    What about using an assembly dll in vb.net, they don't need registering do they?

    If you're using vb6, it's far more efficient to use an object reference rather than the CreateObject() method - your program will use less memory & operate faster.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  7. #7
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Originally posted by alex_read
    What about using an assembly dll in vb.net, they don't need registering do they?

    They surely do not, except in the case if they needed to be added to the Global Assembly Cache which is for all intents and purposes, registering, but that is of course, not necessary in many cases.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  8. #8
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253
    You CANNOT use an ActiveX DLL without registering. There is NO workaround for that.
    Not strictly true - you could do the work of the SCM yourself - but I wouldn't recommend it . . .


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