Calling a C++ dll with unsigned char* parameters

unsigned char*  等价 BYTE*

例1:

C++:

int __stdcall LIVESCAN_GetFPRawData(int nChannel, unsigned char *pRawData);


C#

[DllImport("GALS1701.dll", EntryPoint = "LIVESCAN_GetFPRawData", CallingConvention = CallingConvention.Cdecl)]

unsafe public static extern int GetFPRawData(int nChannel, byte* pRawData);
unsafe

{

    Byte[] bytes = new Byte[400 * 400 + 1078];

    //就是固定“fixed 语句禁止垃圾回收器重定位可移动的变量”

    fixed (byte* array = bytes)

    {

        Livescan.GetFPRawData(0, array);

    }

}

 例2:

C++

extern "C" _declspec(dllexport) int Auto_Capture(BYTE *pBmpData)

C#

[DllImport("LivescanDll.dll", EntryPoint = "Auto_Capture", CallingConvention = CallingConvention.Cdecl)]

public static extern int Auto_Capture(Byte[] pBmpData);
Byte[] bytes = new Byte[400 * 400 + 1078];

int result = Livescan.Auto_Capture(bytes);

 

你可能感兴趣的:(parameter)