PInvoke Marshalling....



Greetings!

I'm trying to call this method in a c# app...

SNAPIDLL_API int __stdcall SNAPI_SetCapabilitiesBuffer(HANDLE
DeviceHandle, unsigned char *pData, long max_length);

So far I've got this:
[DllImport("Dependencies\\SNAPI.DLL")]
public static extern int SNAPI_SetVersionBuffer(IntPtr DeviceHandle,
StringBuilder pData, long max_length);

Keep getting a PInvokeStackImbalance error and I think it's the 2nd paramter
pData because I've referenced the device handler and the long typedef is
pretty obvious.

For the 2nd paramter I've tried the following without success:
byte[]
char[]
string
StringBuilder
[MarshalAs(UnmanagedType.AnsiBStr)] string

HELP!
Thanks.
Dan.


.



Relevant Pages

  • Re: PInvoke Marshalling....
    ... API manual, I'll have a global buffer space that I register with the API ... Or is the string written to when the ... public static extern int SNAPI_SetVersionBuffer(IntPtr DeviceHandle, ... StringBuilder pData, int max_length); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: PInvoke Marshalling....
    ... Or is the string written to when the message ... Does the parameter as a StringBuilder marshall this data ... public static extern int SNAPI_SetVersionBuffer(IntPtr DeviceHandle, ... StringBuilder pData, int max_length); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: PInvoke Marshalling....
    ... public static extern int SNAPI_SetVersionBuffer(IntPtr DeviceHandle, ... if the pData parameter is not going to be written to by the API ... you can pass it as a string. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Pointers
    ... But population unsigned char* with Image Data ... "David Wilkinson" wrote: ... unsigned char *pData; ... bool classB::B(unsigned char *pTemp) ...
    (microsoft.public.vc.mfc)

Loading