FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Check if a device was connected
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Check if a device was connected
Posted: Wed May 29, 2013 12:28 PM

How to check if a specific device was connected?
I need to check if a specific USB Printer was connected.

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Check if a device was connected
Posted: Wed May 29, 2013 05:35 PM

Was connected or still is connected ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: Check if a device was connected
Posted: Wed May 29, 2013 08:51 PM

Both works for me.
But know if the device still is connected will provide me a better solution

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Check if a device was connected
Posted: Fri May 31, 2013 12:39 PM
Samir,

I'm not sure what you are looking for, but the function below will tell you if a specified printer is setup on that PC.

FW's own function getPrnName() returns the name of the current printer.

James

Code (fw): Select all Collapse
function isPrinterModel( cModel )
   local aPrinters:= getPrinters(), i:=0, lSuccess:=.f.
   for i = 1 to len( aPrinters )
      if aPrinters[i] = cModel
         lSuccess:=.t.
      endif
   next
return lSuccess
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: Check if a device was connected
Posted: Fri May 31, 2013 06:28 PM

James, the printer isn't recognized as a printer by the OS.
Here in Brazil we have the ECF ( Emissor de Cupom Fiscal ) something like fiscal coupons emitter, thermal printers with a specific firmware that must be used to print valid coupons to collect taxes.
Most of them connect through the serial port, some connect via USB, but create a virtual serial port and a specific brand connects via USB, but creates another type of device (USBIO).

I need to know if this device is connected.

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Check if a device was connected
Posted: Fri May 31, 2013 09:56 PM

Samir,

OK. Well I don't know the answer to that one.

Here is a manual for setting up USB drivers which may help. Perhaps you can find a registry entry that you could search for.

http://www.thesycon.de/usbio/usbio_win_manual.pdf

And here is a little utility program that will list all the USB devices that have ever been connected. It doesn't solve your problem but maybe it will be useful in finding a solution.

http://www.nirsoft.net/utils/usb_devices_view.html

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion