Description:
Black Ice Software no longer supports Delphi programming language. The Samples are provided without technical support.
The Message Capture Delphi sample demonstrates how to capture the printer driver messages sent at every StartDoc, StartPage, EndPage, EndDoc and ChangeDevmode event, using the PIPE interface. The sample writes a message to the list box at every ChangeDevmode event, by default it does not change any values in the BlackIceDEVMODE structure.
The purposes of the Message Capture Delphi sample are:
Capture messages from the Printer Driver for the User in the current Windows Session
Capture all messages for the Administrator from every User who print on the server
The output path and filename can be changed. When the
Output path changed, the sample modifies values of the BlackIceDEVMODE structure.
Note: Only PDF format is supported, when one changes the output path and filename. Filename is not dynamic.
How It Works:
The sample uses the StartCapture function of the BiPrnDrv.ocx. This sample uses the Named Pipe method, which is the most compatible.
NOTE: The printer driver adds a Message Interface ID to the interface name. By default the sample and the OCX uses the Message Interface ID that is currently used by the printer driver, and the printer driver uses the Windows Session ID of the current user as the Message Interface ID. For more information about the Message Interface ID including instructions about how to change the Message Interface ID used by the printer driver, please see the following page in the manual: Message Capture – Using Session ID
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:
32 bit
<RTK Installation Folder>\<RTK 32 bit>\Samples\Sample Source Codes\Delphi\Message Capture Delphi Sample
32 bit
Language |
Project file: |
Compiler: |
Delphi |
MessageCaptureDelphi.dpr |
Delphi 5 |
Delphi |
MessageCaptureDelphi.dproj |
Delphi XE2 |
Additional files needed for redistribution:
For 32 bit Message Capture Delphi sample
- Message Capture Delphi Sample.exe
- blicectr.dll
- BlackIceDEVMODE.dll
- BlackIceDEVMODE.ocx
- BiPrnDrv.ocx (Needs to be registered into the OS)
- SampleSettings.ini (Optional: Change printer name from ini file)
These additional files are located in the following folders.
\<RTK Installation Folder>\<RTK 32 bit>\BiPrnDrv
\<RTK Installation Folder>\<RTK 32 bit>\BlackiceDEVMODE
\<RTK Installation Folder>\<RTK 32 bit>\Samples\Sample Source Codes\C++\
Warning: You must copy the appropriate dll files to the project folder.
How to build the Sample
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 ChangeDevmode messages. Other messages may appear to work, but they will be delayed. This is because ChangeDevmode 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.