Click to See Complete Forum and Search --> : How to write a plain DLL in VB?
bandukoa
November 18th, 1999, 02:50 PM
VB Gurus,
Is there a way to write a simple (i.e. non-ActiveX) DLL in VB that exports functions to be called from a VC program? All help info I was able to find about VB DLLs, describes how to write COM/ActiveX components, and this is not what I need. I have an impression that it cannot be done. Am I wrong?
Thanks in advance.
czimmerman
November 18th, 1999, 06:27 PM
You can set the class's instancing property to GlobalMultiUse. It will still be a COM Object, but you won't have use CreateObject or the new keyword to instantiate it.
Charlie Zimmerman
http://www.freevbcode.com
santulan
November 18th, 1999, 10:22 PM
Hi,
You can create DLL in VB. Just select a new project as DLL. (In VB6.0) Add a module and start writing your own functions. Then you compile it as DLL file from file option.
To include this in your new project, goto reference and include your dll file here. I normally copy my own dll file containing my own useful funtion in System directory where all dll files resides.
Give a try, this is simple and efefctive.
Good luck.
Santulan
Santulan
Chris Eastwood
November 19th, 1999, 02:17 AM
You can't write a DLL in VB that 'exports' functions similar to a standard windows DLL. You could either write a COM/ActiveX DLL, or rewrite the routines in another language (eg. C/C++/Delphi/PowerBasic).
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb
bandukoa
November 19th, 1999, 11:27 AM
Thanks for your reply, Suntulan. Can you clarify a couple of things for me?
First, when creating a new project, there are only 4 options to make it a DLL: ActiveX DLL, ActiveX Document DLL, and I assume that Add-In and ActiveX Control will also create DLLs, which are ActiveX (I am not a VB programmer, so please excuse my ignorance). I DO NOT my DLL to be an ActiveX! Which one do I choose? I am using VB 6.0 (I think it's an Enterprise Edition), but I don't see an option to create a plain DLL project.
Second, asuming there is a way to solve the first problem, what do I need to do to export functions so that I could call them from a C++ program? The reason behind this is that we have a C++ program, that manages different types of "objects". Each type of "object" has a corresponding DLL that implements a set of commonly defined functions in a way this "object" understands. When the C++ program has to perform certain action on a particular "object", it checks its type, loads appropriate DLL, and executes the function. Because all functions with the same name implemented in different DLLs have the same parameters and return types, implementation of the main program is simple. So far, we did everything using C++, but now we have to manage one more "object type" and for a particular reason we cannot write a DLL for it in C++. If I use VB, how do I declare and export these functions, so that they took the same parameters and returned the same values as the rest of my DLLs written in C++, and could be called from a C++ program.
I apologize for such a long question but would really appreciate your answer. Thank you very much!
December 1st, 1999, 09:41 AM
I asked the same question on deja and got the reply that VB only generates activex type dll's and they do not explicitly export the methods in the class, which is a real downer
Now Im looking for a way of exporting the "addressof" the method and using a callback from C++ which I cant get working, or alternatively of doing a create object in C++ and accessing the methods that way.
Again a good example of either would make my day!!
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.