TonnieH
12/19/2005 9:06:00 AM
Hi. This defenitly put me in the right direction. After some tests I made the
following changes :
- declare the functions as 'extern "C" __declspec( dllexport )'
- and set the calling convention to _stdcall instead of _cdecl
Now it works fine. Thx,
Tonnie
"onno" wrote:
> Hi,
>
> you have to create a Module-Definition-File (*.def) for the exported
> function and you have to declare that function with WINAPI (__stdcall) .
>
> Example:
>
>
> ****************************
> * DemoDll.h (for use in other C/C++ projects)
> ****************************
> #include <windows.h>
> int WINAPI DemoStrLen(char *Str);
>
>
> ****************************
> * DemoDll.cpp
> ****************************
> #include <string.h>
> #include "DemoDll.h"
>
> int WINAPI DemoStrLen(char *Str)
> {
> return strlen(Str);
> }
>
>
> ****************************
> * DemoDll.def
> ****************************
> LIBRARY "DemoDll"
> EXPORTS
> DemoStrLen @1
>
>
> ****************************
> * Axapta Job for testing the Dll
> ****************************
> static void DemoDll(Args _args)
> {
> DLL DLL = new DLL("C:\\Dokumente und Einstellungen\\torsten\\Eigene
> Dateien\\Visual Studio 2005\\Projects\\DemoDll\\DemoDll\\Debug\\DemoDll.dll");
> DLLFunction DemoStrLen = new DLLFunction(DLL, "DemoStrLen");
>
> DemoStrLen.arg(ExtTypes::String);
> DemoStrLen.returns(ExtTypes::DWord);
> print DemoStrLen.call("Hallo");
> pause;
> }
>
> This should work. Additionally you can check the exported symbols with
> dependency viewer. Your function should be listed with the name you defined
> in your sources.
>
> Regards,
> Onno