开发者社区> 问答> 正文

C#调用C++动态库参数转换

用C#调用C++封装好dll,这个动态库的方法如下:long GetImageData( LPCTSTR i_strImageID, long i_nPhysicalX, float i_fMag,
long o_nPhysicalWidth, long o_nPhysicalHeight, void i_pBuffer, long io_nBufferSize) ,请问对应的C#方法参数如何写?

展开
收起
a123456678 2016-03-09 10:10:39 2886 0
1 条回答
写回答
取消 提交回答
  • C++
    extern "C"__declspec(dllexport)
    void GetImageData(char*strImageID,int i_nPhysicalX, float i_fMag, int o_nPhysicalWidth, 
    int o_nPhysicalHeight, ushort* i_pBuffer, int* io_nBufferSize)
    
    c#
    [DllImport("xxxxx.dll",EntryPoint="GetImageData")]
    public static unsafe extern void GetImageData(char*strImageID,int i_nPhysicalX, float i_fMag, int o_nPhysicalWidth, 
    int o_nPhysicalHeight, ushort* i_pBuffer, int* io_nBufferSize)
    
    c#中
    string strImageID_ptr="A0001"
    char*strImageID = (char*)Marshal.StringToCoTaskMemAnsi(strImageID_ptr)
    ushort[,] i_pBuffer_t=new double[10,10]
    ushort* i_pBuffer =&i_pBuffer_t[0,0]
    
    
    2019-07-17 18:55:27
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
使用C++11开发PHP7扩展 立即下载
GPON Class C++ SFP O;T Transce 立即下载
GPON Class C++ SFP OLT Transce 立即下载