Hello,
i'm trying to figure out how to make a dll that can be used by a diffrent program that is writion in a diffrent programming langwich i have had alook round the internet but i cna find how to do it.
btw i'm useing dev-c++
Hello,
i'm trying to figure out how to make a dll that can be used by a diffrent program that is writion in a diffrent programming langwich i have had alook round the internet but i cna find how to do it.
btw i'm useing dev-c++
Last edited by MK4554; 04-04-2006 at 01:38 PM.
You'll then need to use LoadLibrary() and GetProcAddress(). There might be other ways but this is how I would do it; google them.
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
erm yeh thats how you load the dll into another program but i'm trying to also figgure out how to make it becuse i used dev-cpp dll and i couldnt get it to work btw i was trying to include it to vb6
thanks
1 or 0, Alive Or Dead!
-------------------------
OS: Windows XP
Complier: MinGW
IDE: Dev-cpp
you have to surround all the functions with extern "C" to prevent the compiler from mangling the names
Or just simply put the functions in a *.c file so that it gets compiled as C and not C++.Code:#ifdef _cplusplus extern "C" { #endif // your code here #ifdef _cplusplus } #endif
Don't forget to export the symbols
For more information google for Mixed Language Programming
Last edited by Ancient Dragon; 04-04-2006 at 02:07 PM.
ok thanks thats helpful but can anyone show me what a basic dll looks like so i know my one is right?
1 or 0, Alive Or Dead!
-------------------------
OS: Windows XP
Complier: MinGW
IDE: Dev-cpp
A basic dll has only one function -- DllMain() which is similar to main() in a normal C/C++ program. And you compiler will generate the code for that. You will want to manually create a header file that contains the prototypes of the functions you want to export. This is for other C/C++ programs that will use your dll, but won't probably need it for VB6. I don't know how you will declare the function in VB6.
This will export one function -- foo().
Code:// This is the C source file // includes here #include <all includes here> #ifdef __cplusplus extern "C" { #endif __declspec( dllexport ) int foo() { return 0; } #ifdef __cplusplus } #endif
Last edited by Ancient Dragon; 04-04-2006 at 03:41 PM.