I am building an application where I need to integrate Dynamic Link Library runtime in c#. I am facing problem in calling one C function from C#.
DLL Function:
typedef void *JCCP_PROPERTY_HANDLE;
typedef void *JCCP_HANDLE;
JCCP_RESULT __JCCP_FUNCTION__ jccpGetProperty(
JCCP_HANDLE hjccp,
const char *name,
JCCP_PROPERTY_HANDLE *phproperty);
In Function Definition File:
_jccpGetProperty @49
Usage- C example:
JCCP_HANDLE m_hjccp = jccpAllocateHandle();
JCCP_PROPERTY_HANDLE hprop;
jccpGetProperty(m_hjccp, name, &hprop);
If this function executes successfully, It return 0.
Now I want to call this function (jccpGetProperty) in C#, but I dont know how to call this function in C#.
I have tried so far:
Declaration:
IntPtr hjccp;
[DllImport(DLL_NAME, EntryPoint = "_jccpAllocateHandle", CallingConvention = CallingConvention.Cdecl)]
[DllImport(DLL_NAME, EntryPoint = "_jccpGetProperty", CallingConvention = CallingConvention.Cdecl), UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public static extern IntPtr jccpGetProperty(IntPtr hjccp, string name, ref IntPtr handle);
In Main Function:
hjccp = jccpAllocateHandle();
IntPtr handle = IntPtr.Zero;
var result = jccpGetProperty(hjccp, "tag", ref handle);
I dont get any exception but I dont get 0 in response, I get 17 in response which is request discarded code. Can anybody guide me that how to call jccpGetProperty() in C# properly?
I am confused that how can I send third parameter to jccpGetProperty function through C#.
Thanks.