问题描述
在此之前我发布我的问题。我曾尝试使用DLLImport在C#中调用C ++方法(它位于名为SDK.dll的DLL文件中)。但是我遇到了一个问题:
我曾尝试使用DLLImport在C#中使用这个C ++代码。
RegisterVideoPreviewCB(HANDLE hChannel,PVOID pContext,VideoCaptureCB_Ptr pCB);
我可以转换HANDLE和VideoCaptureCB_Ptr之外的PVOID。我知道我在C#中没有VideoCaptureCB_Ptr的定义。
我回头看看SDK.h文件。我看到这个代码
typedef void (CALLBACK * VideoCaptureCB_Ptr)(PVOID pContext,BYTE * apData [ 3 ],VideoSampleInfo_T * pVSI);
typedef struct _VideoSampleInfo_T
{
ULONG idFormat; //
ULONG lSignalState;
int nLen; // 未用于原始视频数据(例如YUV420)
int nWidth;
int nHeight;
int anPitchs [ 3 ]; // 仅用于原始视频数据(例如YUV420)
ULONG dwMicrosecsPerFrame; // 1000 * 1000 / FPS
ULONG字段;
int iSerial;
} VideoSampleInfo_T;
我想我必须使用DllImport来在C#中声明RegisterVideoPreviewCB之前声明_VideoSampleInfo_T和VideoCaptureCB_Ptr。
所以任何人都可以帮助我使用DllImport或者某些(例如:在C#中重新声明它) )在C#中制作VideoCaptureCB_Ptr定义。所以我可以把它传递给RegisterVideoPreviewCB定义的参数。
提前谢谢。
Before I post my question in here. I haved tried to using DLLImport to call an C++ method ( it's in an in DLL file named SDK.dll ) in C# . But i encountered a problem:
I have tried to use DLLImport to use this C++ code in C#.
RegisterVideoPreviewCB(HANDLE hChannel, PVOID pContext, VideoCaptureCB_Ptr pCB);
I can convert the HANDLE and PVOID except the VideoCaptureCB_Ptr. I know I don't have the definition of VideoCaptureCB_Ptr in C#.
I look back at the SDK.h file. I see this code
typedef void (CALLBACK * VideoCaptureCB_Ptr)(PVOID pContext, BYTE * apData[3], VideoSampleInfo_T * pVSI); typedef struct _VideoSampleInfo_T { ULONG idFormat; // ULONG lSignalState; int nLen; // not used for raw video data(e.g. YUV420) int nWidth; int nHeight; int anPitchs[3]; // only used for raw video data(e.g. YUV420) ULONG dwMicrosecsPerFrame; // 1000*1000/FPS ULONG field; int iSerial; } VideoSampleInfo_T;
I think I have to use DllImport to declare the _VideoSampleInfo_T and the VideoCaptureCB_Ptr before declare the RegisterVideoPreviewCB in C#.
So could anyone help me to use the DllImport or someway (such as: re-declare it in C#)to make an VideoCaptureCB_Ptr definition in C#. So I can pass it to parametter of RegisterVideoPreviewCB definition.
Thanks in advance.
这篇关于DLLImport使用C#中的C ++代码与struct&原型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!