示例#1
0
        /// <summary>
        /// Get List of Available Card Printers
        /// </summary>
        private string getDeviceList()
        {
            // get device list
            deviceList_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SmartComm2.SMART_PRINTER_LIST)));
            int convertedPointer = (int)deviceList_ptr.ToInt64();

            printerresponse = SmartComm2.SmartComm_GetDeviceList2((long)deviceList_ptr);
            object listUndefined = Marshal.PtrToStructure(deviceList_ptr, typeof(SmartComm2.SMART_PRINTER_LIST));

            deviceList = (SmartComm2.SMART_PRINTER_LIST)listUndefined;

            if (printerresponse != SmartComm2.SM_SUCCESS)
            {
                Marshal.FreeHGlobal(deviceList_ptr);
            }

            int i;

            SmartComm2.SMART_PRINTER_ITEM smartItem = deviceList.item[0];

            for (i = 0; i <= deviceList.n - 1; i++)
            {
                printerStrDescription = new string(deviceList.item[i].desc);
            }

            Marshal.FreeHGlobal(deviceList_ptr);
            return(printerStrDescription);
        }
示例#2
0
        private int AllocateCardprinter()
        {
            printerStatus = "initializing printer";
            // get device list
            int nres;

            deviceList_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SmartComm2.SMART_PRINTER_LIST)));
            int convertedPointer = (int)deviceList_ptr.ToInt64();

            nres = SmartComm2.SmartComm_GetDeviceList2((long)deviceList_ptr);
            object listUndefined = Marshal.PtrToStructure(deviceList_ptr, typeof(SmartComm2.SMART_PRINTER_LIST));

            deviceList = (SmartComm2.SMART_PRINTER_LIST)listUndefined;
            return(nres);
        }