C#调用C++的DLL接口问题。

seaonce 2016-06-14 03:15:50
有没有精通C++和C#的大侠:


我想用C#调用C++的DLL的一个接口,但实在不会C++转C# 请教:


C++接口如下:

函数:
int32_t DPSDK_CALL_METHOD DPSDK_QueryAlarmInfo

( IN int32_t nPDLLHandle,

IN Alarm_Query_Info_t* pQuery,

INOUT Alarm_Info_t* pInfo,

IN int nFirstNum,

IN int nQueryCount,

IN int nTimeout = DPSDK_CORE_DEFAULT_TIMEOUT );

参数:
nPDLLHandle

[in] sdk实例句柄

pQuery

[in] 查询信息,参考表1

pInfo

[in,out] 报警信息,参考表4

nFirstNum

[in] 从第几个开始获取

nQueryCount

[in] 获取记录个数

nTimeout

[in] 超时,默认DPSDK_CORE_DEFAULT_TIMEOUT

对象如下:

typedef struct tagAlarmQueryInfo

{

char szCameraID[DPSDK_CORE_CHL_ID_LEN]; // 通道ID

uint64_t uStartTime; // 开始时间

uint64_t uEndTime; // 结束时间

dpsdk_alarm_dealwith_e nDealWith; // 报警处理类型,参考表2

dpsdk_alarm_type_e nAlarmType; // 报警类型,参考表3

}Alarm_Query_Info_t;

typedef struct tagAlarmInfo

{

IN uint32_t nCount; // 请求录像数

OUT uint32_t nRetCount; // 实际返回个数

OUT Single_Alarm_Info_t* pAlarmInfo; // 报警信息,参考表5

}Alarm_Info_t;

typedef struct tagSingleAlarmInfo

{

dpsdk_alarm_type_e nAlarmType; // 报警类型,参考表3

dpsdk_event_type_e nEventType; // 事件状态,参考表6

char szDevId[DPSDK_CORE_DEV_ID_LEN]; // 报警设备ID

uint32_t uChannel; // 报警通道

uint64_t uAlarmTime; // 报警时间

dpsdk_alarm_dealwith_e nDealWith; // 处理意见,参考表2

}Single_Alarm_Info_t;

请问C#调用这个接口该怎么写?
...全文
138 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
小程序员 2016-06-14
  • 打赏
  • 举报
回复

 public extern int DPSDK_CALL_METHOD DPSDK_QueryAlarmInfo
(Intptr nPDLLHandle, ref Alarm_Query_Info_t pQuery, ref Alarm_Info_t pInfo, 
 int nFirstNum, int nQueryCount,  int nTimeout = DPSDK_CORE_DEFAULT_TIMEOUT );

struct Alarm_Query_Info_t
{
    char            szCameraID[DPSDK_CORE_CHL_ID_LEN];        // 通道ID
    Int64      uStartTime;                               // 开始时间
    Int64       uEndTime;                                 // 结束时间
    dpsdk_alarm_dealwith_e  nDealWith;                        // 报警处理类型,参考表2
    dpsdk_alarm_type_e      nAlarmType;                       // 报警类型,参考表3
}

struct Alarm_Info_t
{
    int     nCount;                                  // 请求录像数
    OUT int   nRetCount;                               // 实际返回个数,可能是ref int
    ref Single_Alarm_Info_t pAlarmInfo;                    // 报警信息,参考表5
}
struct Single_Alarm_Info_t
{
    dpsdk_alarm_type_e      nAlarmType;                     // 报警类型,参考表3
    dpsdk_event_type_e      nEventType;                     // 事件状态,参考表6
    char            szDevId[DPSDK_CORE_DEV_ID_LEN];         // 报警设备ID
    int        uChannel;                               // 报警通道
    Int64        uAlarmTime;                             // 报警时间
    dpsdk_alarm_dealwith_e  nDealWith;                      // 处理意见,参考表2
}
seaonce 2016-06-14
  • 打赏
  • 举报
回复
有哪位大侠给翻译成C#
qq_34290751 2016-06-14
  • 打赏
  • 举报
回复
静等专家

110,547

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧