Dear All,

I would like to communicate directly with USB and parallel local
printers using CreateFile, WriteFile and ReadFile functions from the
Windows API.

To retrieve local printers connected to a PC, I used the setupapi with
the printer setup class as follow :

SetupDiGetClassDevs(&GUID_DEVCLASS_PRINTER, 0, 0, DIGCF_PRESENT);

Then I could enumerate the printers using SetupDiEnumDeviceInfo ().

To communicate with the printers using CreateFile, WriteFile and
ReadFile functions, I figured out I had to retrieve the "symbolic name"
of the printers using SetupDiGetDeviceInterfaceDetail ().

How can I get the device interfaces of the printers I retrieved using
SetupDiEnumDeviceInfo () ? What is the link between setup class and
interface class ?

Best regards,

Guillaume.

Re: Link between setup classes and interface classes. by Maxim

Maxim
Fri Apr 22 11:36:46 CDT 2005

I'm not sure this is possible for USB printers. The kernel mode driver for
USB printer can assume that its only user-mode client is USBMON.DLL, which can
have some set of undocumented IOCTLs to communicate to the kernel mode part.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com

"Guillaume" <guillaume.gerard@gmail.com> wrote in message
news:1114156672.040596.240050@l41g2000cwc.googlegroups.com...
> Dear All,
>
> I would like to communicate directly with USB and parallel local
> printers using CreateFile, WriteFile and ReadFile functions from the
> Windows API.
>
> To retrieve local printers connected to a PC, I used the setupapi with
> the printer setup class as follow :
>
> SetupDiGetClassDevs(&GUID_DEVCLASS_PRINTER, 0, 0, DIGCF_PRESENT);
>
> Then I could enumerate the printers using SetupDiEnumDeviceInfo ().
>
> To communicate with the printers using CreateFile, WriteFile and
> ReadFile functions, I figured out I had to retrieve the "symbolic name"
> of the printers using SetupDiGetDeviceInterfaceDetail ().
>
> How can I get the device interfaces of the printers I retrieved using
> SetupDiEnumDeviceInfo () ? What is the link between setup class and
> interface class ?
>
> Best regards,
>
> Guillaume.
>



Re: Link between setup classes and interface classes. by Guillaume

Guillaume
Wed Apr 27 04:31:52 CDT 2005

Thanks a lot for your help!

I managed to retrieve the symbolic name of a specific printer. (The
link is the device id.)
I then used CreateFile to open the USB printer.

I tested this method with 2 printers: Lexmark E321 and HP Laserjet 1320
PCL 6.

It works well with the USB Lexmark E321 printer but CreateFile fails
with the HP Laserjet 1320 PCL 6. (Error code ERROR_GEN_FAILURE "A
device attached to the system is not functioning.").

What is that error from?
Is that possible that, for some reasons, the device be locked?