Because RFID reading is used in Web projects, it is necessary to develop Activex. Generally, Activex is developed using VC, VB, etc. However, these two parts are not very familiar, therefore, C # is used to compile Activex. For more information, see network 1. compile WindowsFromControls2. publish WindowsFormControls to Activex3. use this Activex in the web. First, compile the windows Control and do not elaborate on it. (Note that a guid is generated by using the vs tool, which will be used below. My0CBD6597-3953-4B88-8C9F-F58B1B023413) Important classes:
View sourceprint? Using System; using System. runtime. interopServices; namespace RFIDReader {public class ReadRfid {[DllImport ("MasterRD. dll ")] private static extern int rf_init_com (int port, int baud); [DllImport (" MasterRD. dll ")] private static extern int rf_request (short icdev, byte model, ref short TagType); [DllImport (" MasterRD. dll ")] private static extern int rf_write (int icdev, char _ Adr, char _ Data); [DllImp Ort ("MasterRD. dll ")] private static extern int rf_anticoll (short icdev, byte bcnt, ref byte PSNR, ref byte pRLength); [DllImport (" MasterRD. dll ")] private static extern int rf_ClosePort (); public string CardNum {get {return getCardNum () ;}} private string getCardNum () {int post = 4; // call the COM1 port int baud = 9600; int I =-1; byte model = 82; byte b1 = 4; short TagType = 4; byte [] buf1 = new byte [2 00]; try {rf_init_com (post, baud); rf_request (0, model, ref TagType); rf_anticoll (0, 4, ref buf1 [0], ref b1 ); string s1 = ""; for (I = 0; I <b1; I ++) {s1 = s1 + System. convert. toString (long. parse (buf1 [I]. toString (), 16 ). toUpper ();} rf_ClosePort (); if (s1 = "0000") {throw (new Exception ();} return s1 ;} catch (Exception) {} return "" ;}}} view sourceprint? View sourceprint? Using System; using System. collections. generic; using System. linq; using System. text; using System. runtime. interopServices; namespace RFIDReader {[ComImport, guidattriort ("<SPAN style =" COLOR: #800000 "> 0CBD6597-3953-4B88-8C9F-F58B1B023413 </SPAN> <SPAN style =" COLOR: #800000 "> </SPAN>")] [InterfaceTypeAttribute (ComInterfaceType. interfaceIsIUnknown)] public interface IObjectSafety {[PreserveSig] void GetInterfacceSafyOptions (int riid, out int trim, out int pdwEnabledOptions); [PreserveSig] void trim (int riid, int trim, int dwEnabledOptions) ;}} using System; using System. collections. generic; using System. componentModel; using System. drawing; using System. data; using System. linq; using System. text; using System. windows. forms; using System. runtime. interopServices; using CJ; namespace RFIDReader {[Guid ("0CBD6597-3953-4B88-8C9F-F58B1B