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++
Printable View
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++
You'll then need to use LoadLibrary() and GetProcAddress(). There might be other ways but this is how I would do it; google them.
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
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
ok thanks thats helpful but can anyone show me what a basic dll looks like so i know my one is right?
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