Hello people,
I wanted to know what the format is for writing a DLL...is it just like writing an EXE file with a different template? I don't understand what the code means in the DLL template.
Thank you!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A DLL is just a piece of executable code, although with some minor differences in respect to a regular .EXE file. The most significant are:
The DLL is always invoked from another executable, even a DLL.
The DLL has certain "entry points", usually functions (although can be also regular variables and classes) who are "visible" from outside. Is to say the functionalities who the DLL offer to its users. All other code can't be seen from outside the DLL. This visibility of this objects is indicated by certain conventions (_export).
Because the DLLs can be used from executables made from different languages, when the visible object is a function, the calling convention should be know; by convention this used to be extern "C".
If the DLL is to be used in Windows, need to have an "initial" special function who deal with the DLL's load/unload process. This function has this design:
BOOL WINAPI DllMain (HINSTANCE hIn, DWORD dwd, LPVOID lpv) {
switch (dwd) {
case DLL_PROCESS_ATTACH:
// ...
break;
case DLL_PROCESS_DETACH:
// ...
break;
case DLL_THREAD_ATTACH:
// ...
break;
case DLL_THREAD_DETACH:
// ...
break;
}
return true; // or false if error
}
The rest is... sintactic sugar :- )
Old newbie
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello people,
I wanted to know what the format is for writing a DLL...is it just like writing an EXE file with a different template? I don't understand what the code means in the DLL template.
Thank you!
A DLL is just a piece of executable code, although with some minor differences in respect to a regular .EXE file. The most significant are:
The DLL is always invoked from another executable, even a DLL.
The DLL has certain "entry points", usually functions (although can be also regular variables and classes) who are "visible" from outside. Is to say the functionalities who the DLL offer to its users. All other code can't be seen from outside the DLL. This visibility of this objects is indicated by certain conventions (_export).
Because the DLLs can be used from executables made from different languages, when the visible object is a function, the calling convention should be know; by convention this used to be extern "C".
If the DLL is to be used in Windows, need to have an "initial" special function who deal with the DLL's load/unload process. This function has this design:
BOOL WINAPI DllMain (HINSTANCE hIn, DWORD dwd, LPVOID lpv) {
switch (dwd) {
case DLL_PROCESS_ATTACH:
// ...
break;
case DLL_PROCESS_DETACH:
// ...
break;
case DLL_THREAD_ATTACH:
// ...
break;
case DLL_THREAD_DETACH:
// ...
break;
}
return true; // or false if error
}
The rest is... sintactic sugar :- )
Old newbie