Recently Edoceo was charged with creating a Port Monitor Driver for the Windows printer subsystem, which will be released shortly. This task was made more difficult by the slowness of the MSDN site, lack of responses on their forums and incorrect or incomplete information provided in the DDK. We have completed the project, this is the story.
Support for developing a Printer Driver is available from Edoceo, please contact us for more information.
This is the core function that the project must implement. The signature of this function on the MSDN site is accurate, but incomplete. Key information is left out, information which we will also not disclose. You can call MS for support, or you can call us for half price.
This is a return value from the InitializePrintMonitor2 call. Use this struct to provide pointers to all the internal functions that a port monitor needs. AddPort, AddPortEx, ConfigurePort, DeletePort are deprectaed, don't use. GetPrinterDataFromPort and SendRecvBidiDataFromPort are used for bidirectional printing.
MONITOR2 M2 = {
sizeof(MONITOR2),
pmEnumPorts,
pmOpenPort,
NULL, /* OpenPortEx */
pmStartDocPort,
pmWritePort,
pmReadPort,
pmEndDocPort,
pmClosePort,
NULL, /* AddPort */
NULL, /* AddPortEx */
NULL, /* ConfigurePort */
NULL, /* DeletePort */
NULL, /* GetPrinterDataFromPort */
pmSetPortTimeOuts,
pmXcvOpenPort,
pmXcvDataPort,
pmXcvClosePort,
pmShutdown,
NULL /* SendRecvBidiDataFromPort */
};
To install the Printer or the Port Monitor either 1) manually call the AddMonitor function or construct and INF file. The documents for INF files leaves out some important information, this sample should help.
; Don't change the GUID
[Version]
ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318}
Class=Printer
DriverVer=06/27/2006,0.0.0.1
Provider="Edoceo, Inc."
Signature="$Windows NT$"
; Indicate I'm a Port Monitor"
[PortMonitors]
"whfpm" = whfpm_mon
; This section name is determined by the above line
[whfpm_mon]
CopyFiles = @whfpd.dll
PortMonitorDll = whfpd.dll
Needs=pscript.oem
[SourceDisksFiles]
whfpd.dll = 1,\debug,
[SourceDisksNames]
1 = "WHFPM Installation Disk",,,
Note: These links have since become 404s, MSDN keeps re-organizing and we don't care enough to change these links every time.
/djb has been working with computers since 1987.
During his career he has been a Desktop Support Specialist, Network Engineer, Systems Analyst, Security Analyst and Solutions Enginner in the hi-tech, bio-tech, financial and legal industries.