A Dll is like an aplication. It has it's own main that is called each time a process loads it in memory
The most basic DllMain would be
Code:
#include <windows.h>
HINSTANCE g_hInst = NULL;
BOOL APIENTRY DllMain( HINSTANCE hModule,DWORD ul_reason_for_call,LPVOID lpReserved){
if(ul_reason_for_call == DLL_PROCESS_ATTACH)
g_hInst = hModule;
return TRUE;
}
Please refer here for more info when loading Dlls
http://msdn.microsoft.com/library/de...oadlibrary.asp
If the module is a DLL not already mapped for the calling process, the system calls the DLL's DllMain function with the DLL_PROCESS_ATTACH value. If DllMain returns TRUE, LoadLibrary returns successfully. If DllMain returns FALSE, the system unloads the DLL from the process address space and LoadLibrary returns NULL.
It is not safe to call LoadLibrary from DllMain. For more information, see the Remarks section in DllMain.
To compile a dll you need to refer to your compiler manual. For Dev-Cpp or MS Visual C++ create a new project and select Win32 Dynamic-link library (dll).
Then inside your source add all the functions you need
and declare then this way
Code:
return_type __declspec(dllexport)__stdcall CALLBACK function_name(arguments){...}
then in your main program you can acess the function inside the dll like this
Code:
HINSTANCE my_dll_handler = LoadLibrary("my_dll.dll" );
return_type (*my_func)(arguments) = (return_type (*)(arguments))GetProcAdress(my_dll_handler,"function_name");
//OR SIMPLER
typedef return_type (*func_type)(arguments);
func_type my_func = (func_type)GetProcAdress(my_dll_handler,"function_name");
func(...);//call the function
As you can see it isn't very simple.
Search http://msdn.microsoft.com/ for info on the windows API functions.
Good luck