با سلام
موضوع:نحوه اتصال یک دستگاه کارت خوان به یک برنامه در سی شارپ
using System.Runtime.InteropServices;
class Call_myMethod
{
[DllImport("mfr.dll", SetLastError = true, CharSet = CharSet.Ansi)]
public static extern int OpenReader(int nPortNo, byte nStationID, byte nReaderID);
[DllImport("mfr.dll", SetLastError = true, CharSet = CharSet.Ansi)]
public static extern int CloseReader(int handle);
[DllImport("mfr.dll", SetLastError = true, CharSet = CharSet.Ansi)]
public static extern int DoMF(int handle, ref MF_MSG mfmsg);
[StructLayout(LayoutKind.Sequential)]
public struct MF_MSG
{
public int nCmd;
public int nBlockNo;
public int nKeyType;
public int nKeyAddr;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] SerialNo;
public int nSerialNoLen;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] KeyValue;
public int nKeyValueLen;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1024)]
public byte[] data;
public int nDataLen;
public int nCardType;
public int nEcho;
public int nBeep;
public int nPassword;
public int nValue;
public int nTransferBlockNo;
public int nValueOpMode;
public int nTimeout;
public int nLength;
public int nHaltAfterCommand;
}