Hallo,
ich habe deinen Quellcode mal so angepasst das man daraus auch einen DLL erstellen kann.
test.c
Code
#include <windows.h>
extern "C" {
__declspec(dllexport) int _stdcall in (int,int,int,int,int,int);
__declspec(dllexport) int _stdcall RectCollision (int,int,int,int,int,int,int,int);
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// attach to process
// return FALSE to fail DLL load
break;
case DLL_PROCESS_DETACH:
// detach from process
break;
case DLL_THREAD_ATTACH:
// attach to thread
break;
case DLL_THREAD_DETACH:
// detach from thread
break;
}
return TRUE; // succesful
}
__declspec(dllexport) int _stdcall RectCollision (int x1,int y1,int w1,int h1,int x2,int y2,int w2,int h2)
{
bool returnvar=false; // 15
if (in(x2,y2,x1,y1,w1,h1))
{
returnvar=true;
}
if (in(x2+w2,y2,x1,y1,w1,h1))
{
returnvar=true;
}
if (in(x2,y2+h2,x1,y1,w1,h1))
{
returnvar=true;
}
if (in(x2+w2,y2+h2,x1,y1,w1,h1))
{
returnvar=true;
}
return returnvar;
}
__declspec(dllexport) int _stdcall in (int po1,int po2,int x,int y,int w,int h)
{
bool myreturn=false;
if (po1>x && po1<x+w && po2>y && po2<y+h)
{
myreturn=true;
}
return myreturn;
}
Alles anzeigen
Mit folgenden Befehlen kann man aus dieser Datei eine, für AutoIt brauchbare DLL, erstellen.
Zitat
g++ -O3 -Wall -c -fmessage-length=0 -otest.o test.c
g++ -s -Wl,--add-stdcall-alias -Wl,--kill-at -shared -otest.dll test.o
Wichtig ist die Funktion DllMain, die zuminstest TRUE zurückgeben muß und das die Funktionen die man mit der DLL zur Verfügung stellen will auch veröffentlicht werden (__declspec(dllexport)).
Edit: extern "C" - im Quellcode hinzugefügt