15 years ago
Call C DLL from js
Im trying ta access a routine in a C DLL but cant get the call right. The code ive tried this far is like this: function testsDLLCall() { var Def_Enviroment, Def_DLL, pointerd...
Victor,
As far as I can see, the function declaration in the script code does not match the C function declaration.
Your C function uses two parameters: char * and int *, and returns an int value --
DD_WRAPPER_API int getDataInt(char* signalName, int* result);
Your script code is --
Def_DLL.DefineProc("getDataInt", VT_LPSTR ,VT_BYREF | VT_PTR);
I suggest changing this script line in the following way --
Def_DLL.DefineProc("getDataInt", vt_lpstr, vt_byref | vt_int, vt_int);
Also, as Alexei wrote, DLL functions must use the stdcall convention. I don't know if DD_WRAPPER_API in your code corresponds to stdcall, but in order for you to be able to call this function, it should correspond to it.