↑ ↓ ← → qqqqxxx <qqqqxxx_member pathlink.com>
writes:
how do i create a dll using dmc compiler
↑ ↓ ← → Bertel Brander <bertel post4.tele.dk>
writes:
qqqqxxx wrote:
how do i create a dll using dmc compiler
A quick example:
First the source of the .dll, put it into dmcdll.c:
#include <windows.h>
#include "dmcdll.h"
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID
lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
__declspec( dllexport ) int DoSomething(int a, int b)
{
return a*b*2;
}
Then a headerfile called dmcdll.h:
__declspec( dllexport ) BOOL APIENTRY DllMain( HANDLE hModule, DWORD
ul_reason_for_call, LPVOID lpReserved);
__declspec( dllexport ) int DoSomething(int a, int b);
And a small test program called dmctest.c:
#include <stdio.h>
#include <windows.h>
#include "dmcdll.h"
int main()
{
printf("Result: %d\n", DoSomething(12, 32));
return 0;
}
Now we can build the dll with this command:
dmc -mn -WD dmcdll.c kernel32.lib
The we create a .lib from the .dll:
implib.exe /noi /system dmcdll.lib dmcdll.dll
And compile our test program, using the .lib:
dmc dmctest.c dmcdll.lib
Then you can run dmctest.exe, which with a bit of
lock should print:
Result: 768
--
Absolutely not the best homepage on the net:
http://home20.inet.tele.dk/midgaard
But it's mine - Bertel