首页 新闻 会员 周边 捐助

How can I access Parallel Port through a printer to print RFID barcode in C#?

0
[待解决问题]

There are two ways using C# that I found on the net:

  1. Using CreateFile and WriteFile from win32 api:

    [DllImport("kernel32.dll ")]
    private static extern int CreateFile(
        string lpFileName,
        uint dwDesiredAccess,
        int dwShareMode,
        int lpSecurityAttributes,
        int dwCreationDisposition,
        int dwFlagsAndAttributes,
        int hTemplateFile);
    
    [DllImport("kernel32.dll ")]
    privatestaticextern bool WriteFile(
        int hFile,
        byte[] lpBuffer,
        int nNumberOfBytesToWrite,
        ref int lpNumberOfBytesWritten,
        ref   OVERLAPPED lpOverlapped
      );
    iHandle =CreateFile("lpt1 ",0x40000000,0,0,3,0,0);

    byte[] mybyte =System.Text.Encoding.Default.GetBytes(Mystring); bool b =WriteFile(iHandle, mybyte, mybyte.Length,ref i,ref x);

     

    It can transport barcode command and print barcode well, but it can not read the status from the parallel port.

  2. Using Inpout32.dll: There are two main functions:

    • short Inp32(short PortAddress)
    • void Out32(short PortAddress, short data)

But the parameter's type is short; how can I transfer print command String at a time?

我本猿类的主页 我本猿类 | 初学一级 | 园豆:2
提问于:2013-09-09 16:14
< >
分享
所有回答(1)
1

现在都用英文提问问题了,时尚啊。

jone_e | 园豆:1410 (小虾三级) | 2013-09-09 17:11

原先是在stackoverflow上提的问,懒得翻译就直接粘过来了

支持(0) 反对(0) 我本猿类 | 园豆:2 (初学一级) | 2013-09-10 01:12
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册