954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Calling a C++ dll with unsigned char* parameters.

I am trying to use an exported function from a C++ dll with the below signature, from within my C# program.

extern "C" __declspec(dllexport) BOOL S_USB_Memsize(unsigned char *buffer)


In my C# code , I am declaring the use of this function with:

[DllImport("RSTUSBIF.dll",CallingConvention = CallingConvention.Cdecl)]
        public static extern int S_USB_Memsize(IntPtr buffer);


I then invoke this by using:

IntPtr buffer = Marshal.AllocHGlobal(8);
      m_success = S_USB_Memsize(buffer);


The call to S_USB_Memsize keeps returning with zero success and buffer empty. I know that the dll is ok because it works when called outwith C#. Anyone shed any light on what might be happening here?

Thanks.

neilelph
Newbie Poster
3 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

Turns out the above works fine - my usb device was causing the problem.

neilelph
Newbie Poster
3 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: