20141118

最近一周做了一个关于仓库管理,拣货任务分配的模块,其中涉及到刷卡自动打印领取任务的功能点。

技术点:

C#调用C++、delphi的动态链接库。动态链接库的调用方法不同。效果也不相同。

DLL位置:执行程序根目录下面

例:

第一种:

[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 调用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)]
//认证秘钥
public static extern Int16 mifs_authentication(uint mode, byte[] Snr, uint Key); //读卡数据 mifs_read(uchar _Adr, uchar *_Data) 出口函数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

最新文章

  1. (转)You might not need jQuery
  2. WebService的两种方式SOAP和REST比较 (转)
  3. 区间DP lightoj 1031
  4. NYOJ题目893十字架
  5. Oracle的内存结构
  6. iOS开发中一些常见的并行处理(转)
  7. Android Studio使用中的异常
  8. Stanford机器学习---第五讲. 神经网络的学习 Neural Networks learning
  9. MYSQL 5.7 主从复制 -----GTID说明与限制 原创
  10. js中邦定事件与解绑支持匿名函数
  11. js日期操作时间看板
  12. "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no freetype in java.library.path
  13. PHP跨域jsonp方式
  14. shell 备份 source code
  15. RESTful restful api Representational State Transfer
  16. 快速构建springmvc+spring+swagger2环境
  17. 【Linux】人脸识别的封装
  18. python的ConfigParser模块
  19. 逆序对__归并排序__树状数组 Inversions SGU - 180
  20. JVM 学习集合

热门文章

  1. DTRACE简介之完结篇3
  2. mysql利用timestamp来进行帖子排序
  3. the apple code
  4. 【Nginx】epoll及内核源码详解
  5. [Spring] Properties for project configuration
  6. netty4与protocol buffer结合简易教程
  7. javascript返回顶端源代码
  8. 开发人员调试工具Chrome Workspace
  9. java 学习第一步---安装JDK以及配置环境变量
  10. git log 常用选项