CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 1999
    Location
    Israel
    Posts
    1,793

    Unrgent please..How use my COM dll???

    Hiya..
    Thanks to cackie i managed to insert my COM dll into vb .
    But it seems that i cannot it.

    this is what i tried to do:

    'global:
    public sh as SEESHELLLib.SeeBaseShell
    ' or i even tries
    public sh as SeeBaseShell

    ' Inside some function:
    private sub DoSomthing()

    Dim code as string
    Dim arr as Byte
    Dim RetVal as Integer

    ' here the compiler always complaines:
    set sh = ???? ' i dont know what to put here.




    Any help will be greatly appriciated
    kishk91


    [email protected]
    ICQ: 13610258

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

    Re: Unrgent please..How use my COM dll???

    TRy:

    public sh as SEESHELLLib.SeeBaseShell'
    ' Inside some function:
    private sub DoSomthing()
    Dim code as string
    Dim arr as Byte
    Dim RetVal as Integer
    set sh = new SEESHELLLib.SeeBaseShell
    sh.Yourmethod
    set sh = nothing
    end sub




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

  3. #3
    Join Date
    Jul 1999
    Location
    Israel
    Posts
    1,793

    Re: Unrgent please..How use my COM dll???

    Hi...
    sorry to tell you that it's not working.
    I know that this is what i need to do
    But i got an error "ActiveX component cannot create object"

    I even tried with CreateObject() and this Class thing..
    Nothing is working.. always the same error

    Thanks
    kishk

    [email protected]
    ICQ: 13610258

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

    Re: Unrgent please..How use my COM dll???

    Your com dll must be registered in the system (regsvr32.exe)
    To use "set xx= new yyy" a reference to it must be set in project references.
    To use createobject, it is enough that the component is registered.

    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.
    ...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
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Unrgent please..How use my COM dll???

    Is the class you are refferring to createable?
    If you made it yourself, you can check it in VB, open the project, select the class and in the properties window there should be selected MultiUse or GlobalMultiUse for the Instancing property.
    If not, you class can only serve as an interface (and that brings us to a bigger chapter, which we are not going to go in on).
    Also, if the class is creatable, make sure that it doesn't need an interface. You can check that in VB by opening the class. If one of the first line is like Implements..., it means you probably need an interface. You can use an interface like this:

    Dim myObject as SomeLib.SomeInterface
    set myObject = CreateObject("SomeLib.SomeClass")



    Note that the SomeLib.SomeInterface must be the same as the part that come after the Implements keyword in the class

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  6. #6
    Join Date
    Jul 1999
    Location
    Israel
    Posts
    1,793

    Re: Unrgent please..How use my COM dll???

    HI... i cannot see the MultiUse nor the GlobalMultiUse.

    And what exactly do you meen by "interface" you meen GUI?? or COM interface??

    I think that i told you before, but i say it again
    This COM dll is just a wrapper for a plain C dll.
    And i have no problems using it from MFC project.

    Regards
    kishk

    [email protected]
    ICQ: 13610258

  7. #7
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Unrgent please..How use my COM dll???

    With interface, I mean COM interface, something that defines the look of a class. If you design your own interface, it would look like the class, but there's no code in it. Then other classes can implement that interface, guaranteing that the class supports all methods and properties described in the class. This allows us to create classes using an interface, but not having to know what class we are really dealing with, we just know it supports the interface, so we can call any method in that interface.
    Of course, by default, a class has at least 1 interface, which isn't directly reffered to in VB (most of the time, this is the name of the class preceded with and underscore, like _Class1 )

    If you want, you can mail the code to me (mail the class project, I don't need the program that instanciates it), and I'll have a look at it.

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  8. #8
    Join Date
    Jul 1999
    Location
    Israel
    Posts
    1,793

    Re: Unrgent please..How use my COM dll???

    Hi there..
    I appreciate your help very much.
    I found what was the problem:
    Like itold you before this COM dll is a warpper for a plain C dll.
    So i did what i though will be the best thing to do:
    I link the plain C dll lib file to the COM dll project and started building the interfaces.
    I turned out that this was the probelm: linking the lib file caused all this mess
    I realy dont know why, i tried to search the problem but failed to find.
    So i loaded the dll dynamicly and used (i guess you know this) GetProcAddress() to get a pointer to the function, and now it is working.

    So 1000's thanks for you patiance for me,
    Best regards
    kishk91


    [email protected]
    ICQ: 13610258

  9. #9
    Join Date
    Aug 2001
    Posts
    26

    Re: Unrgent please..How use my COM dll???

    when ever u create a com object and u want to use in ur application u have to refer it by inserting it in project references then u intantiate it then u declare it as follows

    dim exp as comexp
    set exp = new comexp

    if you do this you can see all the functions present in that com object you can use it and also see the type of class it is i.e either single use or multiple use e.t.c



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