Results 1 to 4 of 4

Thread: Using C++ Dlls in a VB project

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    123

    Using C++ Dlls in a VB project

    I'm trying to use a third party dll with very little documentation. The DLL was compiled in Visual C++, but I'd like to create an interface for it in VB 6.

    Normally when I what to access public methods in DLLs I've built myself I just add it as a project reference, and this exposes the methods nicely.

    Well when I try to add this DLL as a reference I get the message "Cant add a reference to the specified file.". Is there any way for me to work with this DLL? If so how?

    Oh and as a secondary question...is there a tool with Visual Studio or another program which will give me as much info as possible about the public methods of this DLL? I can get a little bit in dependency walker but not as much as I would like.

    thank you

  2. #2
    Addicted Member
    Join Date
    Feb 2003
    Posts
    237
    if its not an active x dll then the only way to access it is by writing out API like declare statements.

    if you dont have the header file from the dll, then you arent going to have much fun trying to call it.

    you dont know for sure if it was built to work with VB.

    I am not completly sure about C++ dlls

    does C++ automatically mangle the export names?

    I have worked with stdcall C dlls only not really that up on
    the intricies of this subject.

    but if you dont have the header file, you are going to be pretty
    much guessing at the function arguments and have an annoying
    night of crashs trying to figure them out. either that or
    disassemble it and try t determine the arguments from there.

    or, if you have a program that does use the dll, you can watch
    an actual function call in a debugger and that would probably
    help.
    Free Code, papers, tools, and more

    http://sandsprite.com

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    123
    thank you for your response.

    i think i do know the function calls okay, because the DLL came with a crappy little demo written in C. so that is not a major problem. although yes it would be nice to have the header file.

    this VB object interfacing the DLL needs to be COM+, and since all of my other COM objects are in VB, I would like to keep it that way. Also, although I have decent experience in C++, i have yet to code a COM+ object in this language. I believe it would somewhat of a more difficult task than I would like.

    Please explain "API like declare statements". I assume you mean the win API, but I am not very familiar with this.

  4. #4
    Addicted Member
    Join Date
    Feb 2003
    Posts
    237
    yeah like the winapi declare statements

    but there is kind of alot to think of when writing up your own.

    you have to take into account byte length of variables in vb verses C, VB string types are OLE types, all vb arrays are safearray type, the C dll function calling convention , and whether to pass the argument byval or byref

    I am not really a good source on the specifics, I always consult my books when I need to do it but those above are the things you have to take into consideration.

    I have 2 books that go indepth into it, PowerVB from Mat Curland, and Dan Applemans Visual Basic Programmers GUide to teh Win32 API

    Hardcore VisualBasic found on the MSDN CD may also contain the info you need.
    Free Code, papers, tools, and more

    http://sandsprite.com

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