I need to call native library function
(long (WINAPI*)(long, unsigned short *, long, int(__cdecl *)(long, long, eMcamStatus, void*), void*);
in c++ cli visual studio project i have this:
1-structure for native function
ref struct Stuct_Test
{
long ResolutionIndex;
long BinningFactor;
long BitsPerPixel;
String^ DisplayName;
};
2-delegate for call back
delegate int Call_Back_Type(Int32, Int32, Stuct_Test, IntPtr);
3-call back proccessing function
int Call_Back(Int32 Long1, Int32 Long2, Stuct_Test Struct1, IntPtr Void1)
4-pinvoke function
[DllImport("mrfw.dll", EntryPoint = "_McammAcquisitionEx@20")]
static long Camm_Acquisition(Int32, StringBuilder^, Call_Back_Type^, IntPtr);
i am calling it like this
Type_Test^ Test = gcnew Type_Test;
Type_Test::Call_Back_Type^ Call_Back_Function = gcnew Type_Test::Call_Back_Type(Test, &Type_Test::Call_Back);
StringBuilder^ Result_Image;
long Camera_Index = 1;
IntPtr Extra_Parameter;
long Result = Type_Test::Camm_Acquisition(Camera_Index, Result_Image, Call_Back_Function, Extra_Parameter);
and i have exception
Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 'D:\mapx\Mapx\Debug\Mapx.exe'. Additional Information: A call to PInvoke function 'Mapx!Type_Test::Camm_Acquisition' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
What is wrong? How "pinvoke function" should looks like? Where i can found conversion table? May be exist a better way t do this?
Thank you