【求 C# 打开钱箱代码】 本帖最后由 oh_ku 于 2011-05-06 13:24:44 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 写入byte[]数据到打印机,怎么弄出这么多ToString? [DllImport("kernel32.dll", CharSet = CharSet.Auto)] private static extern IntPtr CreateFile(string lpFileName, int dwDesiredAccess, int dwShareMode, int lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, int hTemplateFile); #region 开钱箱 /// <summary> /// 开钱箱 /// </summary> public void OpenDrawer() { try { IntPtr iHandle = CreateFile("LPT1", 0x40000000, 0, 0, 3, 0, 0); if (iHandle.ToInt32() == -1) { MessageBox.Show("没有连接打印机或者打印机端口未打开!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { SafeFileHandle handle = new SafeFileHandle(iHandle, true); FileStream fs = new FileStream(handle, FileAccess.ReadWrite); StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Default); sw.Write(((char)27).ToString() + "p" + ((char)0).ToString() + ((char)60).ToString() + ((char)255).ToString()); sw.Close(); fs.Close(); } } catch (Exception e) { MessageBox.Show(e.Message); } } #endregion 端口是串口COM1的,能不能用这个代码 [原创] 在线更新通用升级工具 免费绿色版 Ver1.0 c#中窗体大小变化时,如何让里面的控件大小也随之改变 一个小白问题 MFC中的函数怎么关联c#的event 使用org.in2bits.MyXls生成excel读取的时候报错 串口中的线程问题,新手,想不明白。谢谢 关于C#处理LSB信息中的一个小疑问 急~~ 高手,这段VB6代码如何用相应的C#改编?没分了,以后补上 一口气问上3个问题,请指教 制作安装盘中怎么判断当前电脑IE版本是否大于5.5 this.menuStrip.Items只能改一级菜单 C# axwindowsmediaplayer 如何添加多个音乐
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr CreateFile(string lpFileName,
int dwDesiredAccess,
int dwShareMode,
int lpSecurityAttributes,
int dwCreationDisposition,
int dwFlagsAndAttributes,
int hTemplateFile); #region 开钱箱
/// <summary>
/// 开钱箱
/// </summary>
public void OpenDrawer()
{
try
{
IntPtr iHandle = CreateFile("LPT1", 0x40000000, 0, 0, 3, 0, 0);
if (iHandle.ToInt32() == -1)
{
MessageBox.Show("没有连接打印机或者打印机端口未打开!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
} else
{
SafeFileHandle handle = new SafeFileHandle(iHandle, true);
FileStream fs = new FileStream(handle, FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Default);
sw.Write(((char)27).ToString() + "p" + ((char)0).ToString() + ((char)60).ToString() + ((char)255).ToString()); sw.Close(); fs.Close();
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
#endregion