usb printer detection with c++

hi there,
please take a look at this project :
http://www.codeproject.com/Articles/14500/Detecting-Hardware-Insertion-and-or-Removal?msg=4822561#xx4822561xx
i want to change this project for this purpose :
when a USB PRINTER is connected show a message that tell us -> hey this is a printer.
which part of this project should i change and how can i separate printer devices from the others?

note:
if you are using visual studio 2010 or higher and get error for this line after conversion :

#define _WIN32_WINNT 0x403

just replace all of such these lines to stdafx.cpp file.
means stdafx.cpp at last should be like this :

1
2
3
4
5
6
// stdafx.cpp : source file that includes just the standard includes
// HWDetect.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#define _WIN32_WINNT 0x403
#include "stdafx.h" 


thanks in advance
Last edited on
You may use EnumPrinters function:

http://msdn.microsoft.com/en-us/library/windows/desktop/dd162692%28v=vs.85%29.aspx

After a device is inserted it may take a while until it is fully installed and functional. Hence the 'Device Interface Name'/GUID might be deceiving.

I'd suggest that you let a thread run for maybe 10 minutes. If you don't detect a change in the printers the new device is likely not a printer.
Topic archived. No new replies allowed.