空間首頁 | 博客 | 好友分享 | 相冊 | 存檔 | 朋友和群組 | 個人資料
iSocceriRun
 

rainfly

 
文章分類
 
缺省  
 
標題搜索
 
 
 
Our Sponsors
 
 
快速導航
 
首頁
論壇
Classified Search Engine
黃頁/二手
北美個人空間
免費注冊
登錄
 
統計
 
點擊: 174956
帖子數量: 215
開辟個人空間: 2011-08-11
最後更新: 2017-03-23
 
RSS訂閱
 
 
 
 
 
 
 
 

CSharp大拿進來: C#調用C代碼生成的DLL

文章內容
  2015-07-07 18:27:39  
C代碼中的一個函數
代碼:

...
__declspec(dllexport) void qwaAccGetVersion( const unsigned short* pusVersionArray[4], const char** pszVersionString, const char ** pszVersionComment )
...


C#中調用時引入
代碼:

[DllImport("qwa_acc.dll", CallingConvention = CallingConvention.Cdecl)]
    public static extern void qwaAccGetVersion(
        [MarshalAs(UnmanagedType.LPTStr)] System.UInt16[] pusVersionArray,
        [MarshalAs(UnmanagedType.LPTStr)] string pszVersionString,
        [MarshalAs(UnmanagedType.LPTStr)] string pszVersionComment);
...


第一個參數寫法肯定是錯的.
[MarshalAs(UnmanagedType.LPTStr)] System.UInt16[] pusVersionArray,

但是應該怎麼寫?

謝謝
∽rainfly∽ 點擊: 0 | 評論: 4 | 分類: 缺省 | 論壇: 電子電玩 | 論壇帖子
 
QR Code
請用微信 掃一掃 掃描上面的二維碼,然後點擊頁面右上角的 ... 圖標,然後點擊 發送給朋友分享到朋友圈,謝謝!
分享:
分享到微信

文章評論

webdriver
無題

2015-07-07 18:46:52 | 引用
無題
LPTStr 是針對char Array的,你應該search UInt16 Pointer的Marshal rule

2015-07-07 18:48:57 | 引用
webdriver
rainfly
回復帖子
webdriver 寫道:
LPTStr 是針對char Array的,你應該search UInt16 Pointer的Marshal rule


Still have no idea how.
researching...

2015-07-08 11:50:52 | 引用
回復帖子
webdriver 寫道:
LPTStr 是針對char Array的,你應該search UInt16 Pointer的Marshal rule


how about this?
代碼:

    [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 4)] UInt16[] pusVersionArray

2015-07-08 12:17:52 | 引用
rainfly

發表評論

The images, logos, trademarks used on this site and all forwarded content are the property of their respective owners.
We are not responsible for comments posted by our visitors, as they are the property of the poster.
All other content of this website is copyrighted by 加西網

 

加西網為北美中文網傳媒集團旗下網站