Click here to Skip to main content
15,891,721 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

Objective-C
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:

Objective-C
_jccpGetProperty @49

Usage- C example:

Objective-C
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:

C#
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:

C#
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.
Posted
Updated 8-Dec-15 20:54pm
v2
Comments
Richard MacCutchan 8-Dec-15 11:32am    
And you expect us to guess whare 17 comes from?
billi_rox 9-Dec-15 2:53am    
No I am confused that how can I send third parameter to jccpGetProperty function through C#.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900