You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
9.1 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace POSV
{
/// <summary>
/// 明华读卡器封装类
/// </summary>
public class Mwrf32
{
[DllImport("mwrf32.dll" , EntryPoint = "rf_init" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern int rf_init(Int16 port , int baud);
[DllImport("mwrf32.dll" , EntryPoint = "rf_exit" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_exit(int icdev);
[DllImport("mwrf32.dll" , EntryPoint = "rf_beep" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_beep(int icdev , int msec);
[DllImport("mwrf32.dll" , EntryPoint = "rf_get_status" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_get_status(int icdev , byte[] state);
[DllImport("mwrf32.dll" , EntryPoint = "rf_load_key" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_load_key(int icdev , int mode , int secnr , byte[] keybuff);
[DllImport("mwrf32.dll" , EntryPoint = "rf_load_key_hex" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_load_key_hex(int icdev , int mode , int secnr , byte[] keybuff);
[DllImport("mwrf32.dll" , EntryPoint = "a_hex" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 a_hex(byte[] asc , byte[] hex , int len);
[DllImport("mwrf32.dll" , EntryPoint = "hex_a" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 hex_a(byte[] hex , byte[] asc , int len);
[DllImport("mwrf32.dll" , EntryPoint = "rf_reset" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_reset(int icdev , int msec);
[DllImport("mwrf32.dll" , EntryPoint = "rf_request" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_request(int icdev , int mode , out UInt16 tagtype);
[DllImport("mwrf32.dll" , EntryPoint = "rf_anticoll" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_anticoll(int icdev , int bcnt , out UInt32 snr);
[DllImport("mwrf32.dll" , EntryPoint = "rf_select" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_select(int icdev , UInt32 snr , out byte size);
[DllImport("mwrf32.dll" , EntryPoint = "rf_card" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_card(int icdev , int mode , byte[] snr); //这里将第三个参数设置为byte数组以便直接返回16进制卡号
//public static extern Int16 rf_card(int icdev, int mode, out UInt32 snr);
[DllImport("mwrf32.dll" , EntryPoint = "rf_authentication" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_authentication(int icdev , int mode , int secnr);
[DllImport("mwrf32.dll" , EntryPoint = "rf_authentication_2" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_authentication_2(int icdev , int mode , int keynr , int blocknr);
[DllImport("mwrf32.dll" , EntryPoint = "rf_read" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_read(int icdev , int blocknr , byte[] databuff);
[DllImport("mwrf32.dll" , EntryPoint = "rf_read_hex" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_read_hex(int icdev , int blocknr , byte[] databuff);
[DllImport("mwrf32.dll" , EntryPoint = "rf_write_hex" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_write_hex(int icdev , int blocknr , byte[] databuff);
[DllImport("mwrf32.dll" , EntryPoint = "rf_write" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_write(int icdev , int blocknr , byte[] databuff);
[DllImport("mwrf32.dll" , EntryPoint = "rf_halt" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_halt(int icdev);
[DllImport("mwrf32.dll" , EntryPoint = "rf_changeb3" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_changeb3(int icdev , int sector , byte[] keya , int B0 , int B1 ,
int B2 , int B3 , int Bk , byte[] keyb);
[DllImport("mwrf32.dll" , EntryPoint = "rf_pro_rst" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_pro_rst(int icdev , byte[] _Data);
[DllImport("mwrf32.dll" , EntryPoint = "rf_pro_trn" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_pro_trn(int icdev , byte[] problock , byte[] recv);
[DllImport("mwrf32.dll" , EntryPoint = "rf_ctl_mode" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_ctl_mode(int icdev , byte mode); //受控方式
[DllImport("mwrf32.dll" , EntryPoint = "rf_CtlBackLight" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_CtlBackLight(int icdev , byte cOpenFlag); //控制背光
[DllImport("mwrf32.dll" , EntryPoint = "rf_LcdClrScrn" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_LcdClrScrn(int icdev , byte cLine); //清LCD屏
[DllImport("mwrf32.dll" , EntryPoint = "rf_DispMainMenu" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_DispMainMenu(int icdev); //显示欢迎光临
[DllImport("mwrf32.dll" , EntryPoint = "rf_DispLcd" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_DispLcd(int icdev , byte line , byte type); //显示系统内置操作
[DllImport("mwrf32.dll" , EntryPoint = "rf_DispInfo" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_DispInfo(int icdev , byte line , byte offset , byte[] data); //显示信息,操作前需清屏
[DllImport("mwrf32.dll" , EntryPoint = "rf_disp8" , SetLastError = true ,
CharSet = CharSet.Auto , ExactSpelling = false ,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_disp8(int icdev , int disp_len , byte[] disp_str); //在读写器数码管上显示数字
}
}