private string mPrnPort = "LPT1";
[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);
public void OpenBox()
{
try
{
if (mHandle.ToInt32() == -1)
{
throw new Exception("打开端口失败");
}
else
{
FileStream mFS = new FileStream(mHandle, FileAccess.ReadWrite);
StreamWriter mSW = new StreamWriter(mFS, System.Text.Encoding.Default);
//开钱箱
mSW.Write(((char)27).ToString() + ((char)112).ToString() + ((char)0).ToString() + ((char)60).ToString() + ((char)255).ToString());
mSW.Close();
mFS.Close();
}
}
catch (Exception Ex)
{
throw Ex;
}
}