我写了一个程序,要同时实现  标签打印机和小票打印机的打印我把标签打印机设为了默认的打印机现在的问题是我的小票打印机该如何调用呢?从而实现  标签和小票一起打印出来请求各位大大的帮助,越详细越好

解决方案 »

  1.   

    我也在做
      up
    lz有什么新思路 贴出来大家一起学习  
      

  2.   

    private FileStream fs = null;
            [DllImport("kernel32.dll",CharSet=CharSet.Auto)]//调用系统API打印函数
            public static extern IntPtr CreateFile
            (
                string FileName,          // file name
                uint DesiredAccess,       // access mode
                uint ShareMode,           // share mode
                uint SecurityAttributes,  // Security Attributes
                uint CreationDisposition, // how to create
                uint FlagsAndAttributes,  // file attributes
                string hTemplateFile         // handle to template file
            );
            /// <summary>
            /// 打印一行数据
            /// </summary>
            /// <param name="str">打印的数据</param>
            public void PrintLine(string str)
            {            IntPtr iHandle = CreateFile("COM2", 0x40000000, 0, 0, 3, 0, null);
                if (iHandle.ToInt32() == -1)
                {
                    MessageBox.Show("没 有 连 接 到 打 印 机 !!!");
                    //return;
                }
                else
                {
                    fs = new FileStream(iHandle, FileAccess.ReadWrite);
                    StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Default);   //写数据   
                    sw.WriteLine(str);
                    sw.Flush();
                    sw.Close();
                    fs.Close();
                    MessageBox.Show("打 印 测 试 成 功 !!!"); 
                }
            }