Exemple #1
0
        public static bool OpenCashDrawer(bool justprinted)
        {
            //set justprinted = true if previous line is start_print
            string printername = new PrintDocument().PrinterSettings.PrinterName;

            if (printername.Equals("Microsoft XPS Document Writer"))
            {
                return(true);
            }
            byte[] DrawerOpen       = GlobalFunc.getPrinterODByte();
            IntPtr unmanagedPointer = Marshal.AllocHGlobal(DrawerOpen.Length);

            Marshal.Copy(DrawerOpen, 0, unmanagedPointer, DrawerOpen.Length);
            SendBytesToPrinter(printername, unmanagedPointer, DrawerOpen.Length);
            Marshal.FreeHGlobal(unmanagedPointer);
            return(true);
        }