Check if a device was connected

Check if a device was connected

Postby sambomb » 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
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Check if a device was connected

Postby Antonio Linares » Wed May 29, 2013 5:35 pm

Was connected or still is connected ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42093
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Check if a device was connected

Postby sambomb » Wed May 29, 2013 8: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
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Check if a device was connected

Postby James Bott » 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: Select all  Expand view
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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Check if a device was connected

Postby sambomb » Fri May 31, 2013 6: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
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Check if a device was connected

Postby James Bott » Fri May 31, 2013 9: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 104 guests