bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

C#怎么調(diào)用C++動(dòng)態(tài)鏈接庫

這篇文章主要講解了“C#怎么調(diào)用C++動(dòng)態(tài)鏈接庫”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“C#怎么調(diào)用C++動(dòng)態(tài)鏈接庫”吧!

成都創(chuàng)新互聯(lián)于2013年開始,先為鼓樓等服務(wù)建站,鼓樓等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為鼓樓企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。

當(dāng)VC等調(diào)用C#寫的COM時(shí),用regasm   /tlb生成TLB文件,也可用tlbexp.exe,在VC等中加載TLB文件,當(dāng)用C#調(diào)用VC等寫的COM時(shí),用tlbimp.exe,你可以寫一個(gè)程序調(diào)試一下

下面介紹C#調(diào)用C++動(dòng)態(tài)鏈接庫方法。

添加System.Runtime.InteropServices命名空間

如是COM就直接用靜態(tài)函數(shù)調(diào)用:                  

public   static   int   GetNum(                               int   lFileSeqNo,                               string   sExtType,                               string   sExtNumber,                               string   sFormID,                               string   sOperationDate,                               string   sSystemRegistDate,                               out   int   lCount,                               out   int   lErrorType,                               out   int   lErrorCode)                       {                               int   iRet;                                     WOBCom.ObjClass   obj   =   new   WOBCom.ObjClass();                                                             iRet   =   obj.GetNum(                                       lFileSeqNo,                                       sExtType,                                       sExtNumber,                                       sFormID,                                       sOperationDate,                                       sSystemRegistDate,                                       out   lCount,                                       out   lErrorType,                                       out   lErrorCode);                                     return   iRet;                       }

如不使COM是普通的DLL  

不能直接用  

只能在C++中加一個(gè)對外的接口:  

extern   "C"   __declspec(dllexport)   WOExtConRegObj*   OutGetObjConstructor();     extern   "C"   __declspec(dllexport)   void   OutGetObjDestructor(WOExtConRegObj*   outGetObj);           extern   "C"   __declspec(dllexport)   long   SelectDummyRecord(long   *lErrorType,             long   *lErrorCode,             WOExtConRegObj*   outGetObj);     //     extern   "C"   __declspec(dllexport)   WOExtConRegObj*   OutGetObjConstructor()     {               WOExtConRegObj*   outGetObj   =   new   WOExtConRegObj();                  return   outGetObj;     }           extern   "C"   __declspec(dllexport)   void   OutGetObjDestructor(WOExtConRegObj*   outGetObj)     {               delete   outGetObj;     }           extern   "C"   __declspec(dllexport)   long   SelectDummyRecord(long   *lErrorType,             long   *lErrorCode,             WOExtConRegObj*   outGetObj)     {     return   outGetObj->SelectDummyRecord(lErrorType,     lErrorCode);         }

就可直接用C#調(diào)用C++動(dòng)態(tài)鏈接庫了   

[DllImport("XXX.dll", EntryPoint="SelectDummyRecord", ExactSpelling=false, CallingConvention=CallingConvention.Cdecl)]      private   static   extern   int   SelectDummyRecord(out int lErrorType,out int lErrorCode,int outGetObj);       ///   < summary>      ///   < /summary>      ///   < remarks>      ///   < /remarks>                      ///   < param name="lErrorType">< /param>      ///   < param name="lErrorCode">< /param>      ///   < returns>< /returns>      public int SelectDummyRecord(out int lErrorType,out int lErrorCode)      {              int   intRtn;               intRtn   =   SelectDummyRecord(                      out   lErrorType,                      out   lErrorCode,                      m_OutGetObj);                return   intRtn;      }

這樣就解決了C#調(diào)用C++寫的動(dòng)態(tài)鏈接庫的問題。

感謝各位的閱讀,以上就是“C#怎么調(diào)用C++動(dòng)態(tài)鏈接庫”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對C#怎么調(diào)用C++動(dòng)態(tài)鏈接庫這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識點(diǎn)的文章,歡迎關(guān)注!

分享題目:C#怎么調(diào)用C++動(dòng)態(tài)鏈接庫
標(biāo)題來源:http://vcdvsql.cn/article10/pdcego.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google商城網(wǎng)站、小程序開發(fā)、App設(shè)計(jì)全網(wǎng)營銷推廣品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)