Message Capture C++ Sample

Description:

Demonstrates how to capture the printer driver messages sent at every

StartDoc, StartPage, EndPage, EndDoc. 

 

The purposes of the Message Capture C++ sample are:

1.    Capture messages from the Printer Driver for the User in the current Windows Session

2.    Capture all messages for the Administrator from every User who print on the server

 

msg_capt_C++.png

 

 

How It Works:

The printer driver uses a named pipe interface to communicate with the application. The BLICECTR.DLL captures the pipe messages sent by the printer driver and converts them to window messages “WM_” to be used by the application.

 

Trying the Sample, Logging, Configuring

1.    Edit the INI file of the Sample called SampleSettings.ini.

The following options can be specified in the INI files:

[Printer Settings]

Printer Name=<Name of the Black Ice Printer>

[Message Capture]

logfile=c:\MessageCapture.log

Message Interface ID=-1

Description of the settings:

Printer name: Fill in the name of the Black Ice printer to be used by the Sample (without ‘<’ and ‘>’)

logfile: Specifies the log file’s location and name. The sample logs every messages during the printing.

Message Interface ID: Sets the Message Interface ID of the Printer to the specified value. If this value is not set, or set to -1, the sample uses the printer’s current setting. To run multiple instances of the Message Capture Sample using different Message Interface IDs, make  separate copies of the Message Capture Sample and the necessary files listed in the Additional files needed for redistribution section below, in separate directories. This way you can set each copy to a different Printer and Message Interface ID.

2.    Start the sample application, and start printing to the configured printer driver. The captures messages must appear on the sample’s user interface

Sample Source Code Folder Location:

<RTK Installation Folder>\<RTK 32/64 bit>\Samples\Sample Source Codes\C++\Message Capture C++ Sample  

 

Solution files

Compilers

Message Capture C++ Sample_VS2015.sln

Visual Studio 2015

Message Capture C++ Sample _VS2017.sln

Visual Studio 2017

Message Capture C++ Sample _VS2019.sln

Visual Studio 2019

Message Capture C++ Sample _VS2022.sln

Visual Studio 2022

 

 

Additional files needed for redistribution:

 

-           Message Capture C++ Sample.exe

-           blicectr.dll

-           BlackIceDEVMODE.dll

-           SampleSettings.ini (Optional: Change printer name from ini file)

 

These additional files are located in the following folders.

\<RTK Installation Folder>\<RTK 32/64 bit>\BiPrnDrv

           \<RTK Installation Folder>\<RTK 32/64 bit>\BlackiceDEVMODE

\<RTK Installation Folder>\<RTK 32/64 bit>\Samples\Sample Source Codes\C++\

Warning: You must copy the appropriate dll files to the project folder.

 

Note: Please make sure that you use the appropriate Resource ToolKit, there are two different RTKs.

- API/RTK for 32/64 bit Windows 11,10, 8.1, 7

- API/RTK for 32/64 bit Windows Server 2022/2019/2016/2012

 

Using Message Capture and Printing from the Same Process

 

If you wish to extend the Message Capture samples with printing using AutoPrint, or otherwise combine message capture and printing in the same application, the printing thread must be separated from the message capture thread.

 

Printing and capturing messages from the same thread will result in lost BLACKICE_MESSAGE_DEVMODE messages. Other messages may appear to work, but they will be delayed. This is because BLACKICE_MESSAGE_DEVMODE messages will wait for response and eventually time out, while other messages do not wait for response and are queued.

 

Limitations:

A single instance of Printer Driver can interface with either a “Message Capture” sample application or with a “Print to Memory” sample application at the same time.