USBPRN registry entries for 'override' driver

From: Rob Roy (RobRoy_at_discussions.microsoft.com)
Date: 07/30/04


Date: Fri, 30 Jul 2004 15:11:01 -0700

Hello,

I am trying to provide an 'override' driver to replace or supplement USBPRN, which has problems with my printer. Let's say this driver is called "PJUSBPRN.DLL" and also uses "LPT" as the prefix.

Here are the reg entries for the default system USBPRN driver:
--------------------------------------------------------------
[HKEY_LOCAL_MACHINE\Drivers\USB\LoadClients\Default\Default\7\Printer_Class]
   "Prefix"="LPT"
   "Dll"="USBPRN.DLL"

[HKEY_LOCAL_MACHINE\Drivers\USB\ClientDrivers\Printer_Class]
   "Prefix"="LPT"
   "Dll"="USBPRN.DLL"
--------------------------------------------------------------

Now, I could just replace "DLL" with my own "PJUSBPRN.DLL" in each of these places, but now the system will use my driver for all cases instead of the system one...which is OK, since it is just some fixes to the system one leaving it with the same function it had before. But, this seems like not the proper thing to do. But, I am not sure. Comments?

So, I've tried some other things, for example:
--------------------------------------------------------------
[HKEY_LOCAL_MACHINE\Drivers\USB\LoadClients\Default\Default\7_1\PJPrinter_Class]
   "Prefix"="LPT"
   "Dll"="PJUSBPRN.DLL"

[HKEY_LOCAL_MACHINE\Drivers\USB\ClientDrivers\PJPrinter_Class]
   "Prefix"="LPT"
   "Dll"="PJUSBPRN.DLL"
--------------------------------------------------------------

This in fact does work as expected at PnP and Print time. Except, I have noticed the following problem:
When the printer is connected (after hard-reset of device), the LPT1: port is added as expected, but it does NOT get removed when the printer is disconnected. It is as though the system thinks that LPT1: belongs to the USBPRN driver, and so does not allow my driver to remove it...passing a NULL port string to the LPTDeinit function.

Interestingly, if I change the code so that the Prefix is "LPTUSB:", then the system does add/remove this port as expected....but, then it doesn't work to print (which I suppose I could fix in the PortMonitor if I had too...).

Another thing I tried is:
--------------------------------------------------------------
[HKEY_LOCAL_MACHINE\Drivers\USB\LoadClients\Default\Default\7_1\Printer_Class]
   "Prefix"="LPT"
   "Dll"="PJUSBPRN.DLL"

[HKEY_LOCAL_MACHINE\Drivers\USB\ClientDrivers\Printer_Class]
   "Prefix"="LPT"
   "Dll"="PJUSBPRN.DLL"
--------------------------------------------------------------

This presents the issue that now you have two different drivers pointing to the same identical "Printer_Class" registry setting, one of them wishing to use USBPRN.DLL, and the other wishing to use PJUSBPRN.DLL. But, there is only one place to specify the Dll name. So, it would seem that it is necessary to create a different class name for my driver since Printer_Class is already taken. Comments about this? This seems to me to be a really bad design if calling the class "Printer_CLass" is a requirement....which I am not sure if it is or not.

Finally, the following website indicates some general USB registry setting info:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceddk40/html/cxconusbdriverregistrysettings.asp

And, it says that:
Subkeys for each driver have the form Group1_ID\Group2_ID\Group3_ID\DriverName.

But, I have tried to format to use our own VID/PID, but it doesn't seem to work. Does anyone have any suggestions for how to format the registry entry to have this use our driver...let's say, our VID=1234 and PID=5678, how would you format the registry keys to load my driver before the default USBPRN is tried?

And, even if we can do this, then the whole "Printer_Class" or "LPT1:" issues I mentioned before may still be problematic for the same reasons.

Any info on any of these issues would be appreciated.

best regards,
Rob Roy