In short: how do I get device path associated with USB POS printer? For instance \\?\usb#vid_5986&pid_0535#200901010001#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
if I know that printer's port is USB001 and I know it's name?
In full: I have this noname POS printer I need to print on. It comes with an SDK, a trivial DLL with functions like OpenPort("USB001"), SendData("hello world") and ClosePort(), which is OK for simple printing. It isn't OK if you need to reprogram the printer - SendData's null terminated argument prevents you from sending zeros to the printer, which is absolutely necessary for certain commands.
I spent some time researching if I could find some other way, didn't find anything substantial. Finally I found this article about Setupapi.lib and gave it a try: I wrote trivial program that enumerates all device paths, ran it with the printer on, ran it with the printer off, device path which disappeared I used as an argument to CreateFile, wrote data into opened handle and - hooray! - it worked. Printer did print the data I sent there. :)
And now I need more simple and elegant way to get this device path. I am still digging into Setupapi.lib reference, but maybe someone could give me a hint to speed up the process or suggest alternative route?
Thanks in advance.