日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

动态调用链接库(dll) 续

發(fā)布時間:2025/3/15 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 动态调用链接库(dll) 续 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

20141118

最近一周做了一個關(guān)于倉庫管理,揀貨任務(wù)分配的模塊,其中涉及到刷卡自動打印領(lǐng)取任務(wù)的功能點。

技術(shù)點:

C#調(diào)用C++、delphi的動態(tài)鏈接庫。動態(tài)鏈接庫的調(diào)用方法不同。效果也不相同。

DLL位置:執(zhí)行程序根目錄下面

例:

第一種:

[DllImport("shuipiao1.dll", EntryPoint = "checkticket", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]

第二種:

[DllImport("MifsDLL.dll", CharSet = CharSet.Ansi)]

第三種:
[DllImport("MifsDLL.dll", CharSet = CharSet.Ansi, EntryPoint = "mifs_anticoll", CallingConvention = CallingConvention.Cdecl)]

實際案例:

#region 調(diào)用dll接口方法// 打開串口 OpenComm(char *commPort,DWORD baud)[DllImport("MifsDLL.dll", CharSet = CharSet.Ansi)]// [DllImport("MifsDLL.dll", EntryPoint = "OpenComm", SetLastError = true,//CharSet = CharSet.Auto, ExactSpelling = false,//CallingConvention = CallingConvention.StdCall)]//打開串口public static extern Int16 OpenComm(string port, long baud);//裝載密鑰 WINAPI mifs_load_key(uchar _Mode, uchar _SecNr, uchar *Key)[DllImport("MifsDLL.dll", CharSet = CharSet.Ansi)]//打開串口public static extern Int16 mifs_load_key(uint Mode, uint SecNr, byte[] Key);[DllImport("MifsDLL.dll", CharSet = CharSet.Ansi)]//mifs_request_2 尋卡public static extern Int16 mifs_request_2(long mode);[DllImport("MifsDLL.dll", CharSet = CharSet.Ansi, EntryPoint = "mifs_anticoll", CallingConvention = CallingConvention.Cdecl)]public static extern Int16 mifs_anticoll(uint Bcnt, byte[] port);//mifs_select(uchar *_Snr)[DllImport("MifsDLL.dll", CharSet = CharSet.Ansi, EntryPoint = "mifs_select", CallingConvention = CallingConvention.Cdecl)]//選卡public static extern Int16 mifs_select(byte[] port);//mifs_authentication(uchar auth_mode,uchar *snr,uchar key_sector)[DllImport("MifsDLL.dll", CharSet = CharSet.Ansi)]//認(rèn)證秘鑰public static extern Int16 mifs_authentication(uint mode, byte[] Snr, uint Key);//讀卡數(shù)據(jù) mifs_read(uchar _Adr, uchar *_Data) 出口函數(shù)16byte[DllImport("MifsDLL.dll", CharSet = CharSet.Ansi, EntryPoint = "mifs_read", CallingConvention = CallingConvention.Cdecl)]public static extern Int16 mifs_read(uint Adr, byte[] Data);//int WINAPI mifs_write(uchar _Adr, uchar *_Data) 寫員工號[DllImport("MifsDLL.dll", CharSet = CharSet.Ansi)]public static extern Int16 mifs_write(uint Adr, byte[] Data);// 蜂鳴 mifs_Buzzer(uchar bb)[DllImport("MifsDLL.dll", EntryPoint = "mifs_Buzzer", SetLastError = true,CharSet = CharSet.Auto, ExactSpelling = false,CallingConvention = CallingConvention.StdCall)]public static extern void mifs_Buzzer(int bb);#endregion

?

?

?

?

轉(zhuǎn)載于:https://www.cnblogs.com/cwgyn/p/dll.html

總結(jié)

以上是生活随笔為你收集整理的动态调用链接库(dll) 续的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。