CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2000
    Location
    canada
    Posts
    60

    How to use a dll in vb

    Hi,

    i've a dll and i want to know how to instantiate it and use his functions.

    Thanks in advance.
    I will rate your response.

    "the opposition of the opposites is the engine of becoming"

  2. #2
    Join Date
    Jun 2001
    Location
    Israel
    Posts
    228

    Re: How to use a dll in vb

    you declare a function/functions that you want form it like that:

    public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (byval hwnd as Long, _
    byval wMsg as Long, byval wParam as Long, lParam as Any) as Long




    better declare it in a module, and then you can use it as a regular function

    ----------
    The @host is everywhere!
    ----------

  3. #3
    Join Date
    May 2001
    Location
    Canada
    Posts
    182

    Re: How to use a dll in vb

    Firstly, use "regsvr32" to register your Dll. Then add a Reference to it in VB. (On the VB menue: Project -> Reference)

    Regards,

    Michi
    MCSE, MCDBA

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: How to use a dll in vb


    'if it is a vb dll and if you have it registered on your machine, after you
    'added a reference to it via menu->project->references, you can

    dim aNameOfYourchose as yourdllName.AclassCreatable
    '
    set aNameOfYourchose = new yourdllName.AclassCreatable
    with aNameOfYourchose
    .'after typeing a point, you will have intellisense to help you find methods
    'and properties of your dll
    end with
    'after using, remember to do:
    set aNameOfYourchose= nothing
    'One more help will come from Object Browser:
    'add the reference to the dll then press F2 and search for
    'the dll




    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood,
    Bruno Paris and all the other wonderful people who made and make Codeguru
    a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: How to use a dll in vb

    The others have given the answer but you first need to know if it is an ActiveX dll or not.

    To do this, open the dll with the program called Quickview and scroll down to the very bottom of the resulting output to a secyion called Export Table

    If this section includes the words "DllCanUnloadNow" or "OLESelfRegister" then it is an ActiveX dll - if it has a bunch of others, but none like these two then it is a standard dll.

    For ActiceX dlls you must register them using RegSvr32 and then use them by declaring instances of their class(es) e.g.

    Dim myObj as myDll.myDllClass

    set myObj = new myDll.myDllClass

    myObj.myProperty = "This is a test"




    and for non-ActiveX dlls you need to use the declarations i.e.

    private Declare Sub myProc Lib "myDll.dll" ()

    Call myProc()




    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  6. #6
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: great

    Great!
    -sorry, I am out of votes-

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood,
    Bruno Paris and all the other wonderful people who made and make Codeguru
    a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  7. #7
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: great

    I think we (3 or 4 people who answered this) should get together to write an article on it - this must be one of the most frequently asked questions on this site.

    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  8. #8
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: writing an article

    It sounds good. What is next step?

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood,
    Bruno Paris and all the other wonderful people who made and make Codeguru
    a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  9. #9
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: How to use a dll in vb

    Have a look also here:
    http://codeguru.com/cgi-bin/bbs/wt/s...collapsed&sb=5

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood,
    Bruno Paris and all the other wonderful people who made and make Codeguru
    a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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

Featured