How to use exported classes from DLL without using header.
-
I have written a dll and exported classes. I don't want to give header file to clients. How this can be done. I want only to give lib file and dll to the user.
Why don't you want to provide header files ? It is always done this way...
Cédric Moonen Software developer
Charting control [v1.2] -
I have written a dll and exported classes. I don't want to give header file to clients. How this can be done. I want only to give lib file and dll to the user.
As Cedric said, what's so bad about giving headers? One way or another, their code needs to know how to talk to yours, and the secret of all your dodgy function names will be revealed. That said... Some companies I use just distribute the DLLS. I then use #import to get the COM interfaces from those. But that is COM, and Typelibs, and all sorts of fun... Chances are its more headache than its worth, but it does let their DLLS be used from many languages, include VB. *I* don't care about that, but you might. Iain.
-
I have written a dll and exported classes. I don't want to give header file to clients. How this can be done. I want only to give lib file and dll to the user.
-
That's only to specify that you link to the lib file. You still don't know how the exported classes look like.
Cédric Moonen Software developer
Charting control [v1.2] -
I have written a dll and exported classes. I don't want to give header file to clients. How this can be done. I want only to give lib file and dll to the user.
If you don't want the client to use the exported classes directly from the dll, you can. If the client uses the DLL directly, the exposed classes needs to have its declaration exposed right. If you really want to hide the class declaration that might have some implementation exposed, provide only interface exposed to it similar to COM concepts.
-
I have written a dll and exported classes. I don't want to give header file to clients. How this can be done. I want only to give lib file and dll to the user.
Just a thought (may not work), but if your DLL is simple enough and doesn't require any specific definitions (i.e. structures, macros) maybe this code snippet can help:
typedef int (FAR * Func1_Substract)(int, int); HMODULE hMod = LoadLibrary(_T("test.dll")); Func1_Substract substract = reinterpret_cast<Func1_Substract>( ::GetProcAddress(hMod, "dll_substract_function")); int result = substract(10,10);
-
Just a thought (may not work), but if your DLL is simple enough and doesn't require any specific definitions (i.e. structures, macros) maybe this code snippet can help:
typedef int (FAR * Func1_Substract)(int, int); HMODULE hMod = LoadLibrary(_T("test.dll")); Func1_Substract substract = reinterpret_cast<Func1_Substract>( ::GetProcAddress(hMod, "dll_substract_function")); int result = substract(10,10);
This will also need undecorated export functions (ie, created using extern "C" if you're using C++). It's alway far too easy to break, compared to a header file. It should work though, but there are a few gotchas. Iain.