首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> C語言 >> 關於C語言

C# 視頻監控系列(二):客戶端 SDK 封裝修正記錄(二)

     編輯:關於C語言

記錄 `hikclient.dll` C# 封裝過程中發現的參數類型錯誤及修正,避免踩坑。

修正記錄

1. 2009-02-27:截圖回調參數修正

// 原委托:byte[] pBuf 導致封送錯誤
public delegate void CapPicFun(int handle, 
    [MarshalAs(UnmanagedType.LPArray, SizeConst=152064)] byte[] pBuf, ...);

// 修正:IntPtr 對應非托管指針
public delegate void CapPicFun(int handle, IntPtr pBuf, int nSize, 
    int nWidth, int nHeight, int nStamp, int nType, int nReceived);

同步修正 `MP4_ClientSavePicFile` 簽名:`byte[]` → `IntPtr`。

2. 2009-03-04:錄像函數句柄類型修正

// 原:long StockHandle
public static extern bool MP4_ClientStartCaptureFile(long handle, string fileName);
public static extern bool MP4_ClientStopCapture(long handle);

// 修正:int StockHandle(SDK 實際返回 32 位句柄)
public static extern bool MP4_ClientStartCaptureFile(int handle, string fileName);
public static extern bool MP4_ClientStopCapture(int handle);

重要提醒

  • 僅封裝了項目用到的 API,其餘參數類型可能仍有誤
  • 委托務必聲明為類成員變量,防止 GC 回收導致回調失效
  • 參考 VC++ Demo 與《編程手冊 V4.7》對照修正
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved