private void OpenCardprinter(IntPtr strDesc_ptr, out int nres, out IntPtr hsmart_ptr) { // open device hsmart_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Int64))); nres = SmartComm2.SmartDCL_OpenDevice2((long)hsmart_ptr, (long)strDesc_ptr, SmartComm2.SMART_OPENDEVICE_BYDESC, DMORIENT_LANDSCAPE); if (nres == SmartComm2.SM_SUCCESS) { hsmartprinterid = Marshal.ReadInt64(hsmart_ptr); } Marshal.FreeHGlobal(hsmart_ptr); Marshal.FreeHGlobal(strDesc_ptr); SetPrinterStatus(nres); }
/// <summary> /// Opens first Card printer on card printer device list /// </summary> private void openCardPrinter() { getDeviceList(); // open device hsmartprinter_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Int64))); printerresponse = SmartComm2.SmartDCL_OpenDevice2((long)hsmartprinter_ptr, (long)printerStrDescription_ptr, SmartComm2.SMART_OPENDEVICE_BYDESC, DMORIENT_LANDSCAPE); if (printerresponse == SmartComm2.SM_SUCCESS) { hsmartprinterid = Marshal.ReadInt64(hsmartprinter_ptr); } Marshal.FreeHGlobal(hsmartprinter_ptr); Marshal.FreeHGlobal(printerStrDescription_ptr); moveCardIntoPrinter(); }
/// <summary> /// Moves card into card printer from card stock /// </summary> private void moveCardIntoPrinter() { string strDesc = ""; IntPtr strDesc_ptr; int nres; IntPtr hsmart_ptr; SmartComm2.SMART_PRINTER_INFO DevInfo; IntPtr DevInfo_ptr; getDeviceList(); // acquire destination device information strDesc_ptr = Marshal.StringToHGlobalUni(strDesc); DevInfo_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SmartComm2.SMART_PRINTER_INFO))); nres = SmartComm2.SmartComm_GetDeviceInfo2((long)DevInfo_ptr, (long)strDesc_ptr, SmartComm2.SMART_OPENDEVICE_BYDESC); DevInfo = (SmartComm2.SMART_PRINTER_INFO)Marshal.PtrToStructure(DevInfo_ptr, typeof(SmartComm2.SMART_PRINTER_INFO)); Marshal.FreeHGlobal(DevInfo_ptr); Int32 devGroup = 0; switch ((DevInfo.std.pid >> 4)) { case 0x385: { devGroup = SmartComm2.GROUP_SMART50; // PRINTER_50 break; } case 0x386: { devGroup = SmartComm2.GROUP_SMART50; // PRINTER_50 break; } case 0x387: { devGroup = SmartComm2.GROUP_SMART50; // PRINTER_30 break; } case 0x388: { devGroup = SmartComm2.GROUP_SMART50; // PRINTER_30 break; } case 0x370: { devGroup = SmartComm2.GROUP_SMART70; // PRINTER_70 break; } case 0x351: { devGroup = SmartComm2.GROUP_SMART51; // PRINTER_51 break; } case 0x331: { devGroup = SmartComm2.GROUP_SMART51; // PRINTER_31 break; } } // open device hsmart_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Int64))); nres = SmartComm2.SmartDCL_OpenDevice2((long)hsmart_ptr, (long)strDesc_ptr, SmartComm2.SMART_OPENDEVICE_BYDESC, DMORIENT_LANDSCAPE); if (nres == SmartComm2.SM_SUCCESS) { hsmartprinterid = Marshal.ReadInt64(hsmart_ptr); } Marshal.FreeHGlobal(hsmart_ptr); Marshal.FreeHGlobal(strDesc_ptr); // enter sbs mode if (nres == SmartComm2.SM_SUCCESS) { nres = 111; nres = SmartComm2.SmartComm_SBSStart((long)hsmartprinterid); } // card in if (nres == SmartComm2.SM_SUCCESS) { nres = 111; nres = SmartComm2.SmartComm_CardIn((long)hsmartprinterid); } }