【★asp.net 通过端口调用打印机★】 我写了一个程序,要同时实现 标签打印机和小票打印机的打印我把标签打印机设为了默认的打印机现在的问题是我的小票打印机该如何调用呢?从而实现 标签和小票一起打印出来请求各位大大的帮助,越详细越好 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我也在做 uplz有什么新思路 贴出来大家一起学习 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("打 印 测 试 成 功 !!!"); } } C#窗体应用返回值显示求助 帮忙写个修改的存取过程! 怎么让VS2005使用.NET 4.0? 关于SqlDataReader独占连接问题 网段扫描 关于listBox的问题 请教XtraGrid.GridControl的使用 防止一台服务端不安全,想提供多台服务器端socket问题!很快揭帖! 为什么输出的结果是乱码的?C#(IT菜鸟的提问) 送分了~~求审批流程一份 发布的网站如何获取服务器上绝对路径下的图片 请问大家如何实现这种功能?
up
lz有什么新思路 贴出来大家一起学习
[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("打 印 测 试 成 功 !!!");
}
}