P/Invoke

  • Thread starter Thread starter Y. Sivaram
  • Start date Start date
Y

Y. Sivaram

I want to P/Invoke the following API

extern "C" __declspec(dllexport) BOOL SDIOCamData(HANDLE hCom, Imagecolor
&imgclr,UCHAR *ScreenBufShow,DWORD &ll) ;

typedef struct imgcolor_struct {
UCHAR avRed;
UCHAR avGreen;
UCHAR avBlue;
UCHAR avY;

}Imagecolor;

Is the following VB.NET equivalent is correct??

Private Declare Function SDIOCamData Lib "SDIOCam.dll" (ByVal hCom As
IntPtr, ByRef imgclr As ImageColor, ByRef ScreenBufShow As Byte(), ByRef ll
As IntPtr)

Public Structure ImageColor
Dim avRed As Byte
Dim avGreen As Byte
Dim avBlue As Byte
Dim avY As Byte
End Structure
 
Almost.

Private Declare Function SDIOCamData Lib "SDIOCam.dll" (ByVal hCom As
IntPtr, ByRef imgclr As int, ByVal ScreenBufShow As Byte(), ByRef ll
As int)

And parse imgclr using shift and masking
 
Thanks Alex,

It did the trick. Also earlier I did not include the return value as
Boolean. For anyone else who may be trying this The full declararion is as
follows

Private Declare Function SDIOCamData Lib "SDIOCam.dll" (ByVal hCom As
IntPtr, ByRef imgclr As Integer, ByVal ScreenBufShow() As Byte, ByRef ll As
Integer) As Boolean
Best Regards,

Y. Sivaram
 
Back
Top