Description:
Sometimes it is necessary for the plugin dll to receive information from a standalone application before changing a setting. This example shows how the plugin DLL can communicate with a running c# application to change the printer driver output directory.
Applications changing other parameters such as pdf passwords, can be easily made by rewriteing this sample or please contact the BlackIce technical support for readily available solutions.
How It Works:
This sample consists of two projects. A customized BiPlugin.dll (BiPlugin_OutputDir folder) and the PlugInSample C# application (Plugin Output Dir C# Sample folder).
NOTE: The BiPlugin.dll in the Sample Source Codes\C++\BiPlugIn Output Dir Sample\BiPlugIn_OutputDir\ folder is not the same as the BiPlugin.dll in the Sample Source Codes\C++\Plugin C++ Sample\ folder. Do not mix up the BiPlugin.dll files, because it may cause instability in the sample.
1. When Printing to the Black Ice Printer driver, the driver starts the PlugInSample C# application and calls the BiStartDoc() function of the BiPlugin.dll.
2. In the displayed PlugInSample the user can change the output directory and click on Continue Printing button, or abort the printing. After getting the new output directory from the user the PlugInSample C# application creates an event named “Global\\BIPLUGINSTARTED”, and waits for the BiPlugin.dll to notice and acknowledge it by setting the event object to a signaled state.
3. The application now sends the new output directory using the SendPipeMessage() function of the BiPlugin.dll, at the same time, the BiPlugin dll receives the data using the ReadOutputDirFromPIPE() function.
4. The plugin sets the output directory in the DEVMODE structure and the BiStartDoc() function returns with a TRUE value.
SendPipeMessage function
// C++ declaration
BOOL SendPipeMessage(BOOL bCancelPrinting, LPCTSTR pOutputDirectory);
BOOL bCancelPrinting Set it to TRUE to abort the print job.
LPCTSTR pOutputDirectory Full path of the output directory, for example: “C:\\temp\\”
Returns TRUE on success, FALSE on failure.
// C# declaration
[DllImport("BiPlugin.dll", CharSet = CharSet.Unicode)]
private static extern bool SendPipeMessage(bool CancelPrinting, string OutputDirectory);
bool CancelPrinting; Set it to true to abort the print job.
string OutputDirectory; Full path of the output directory, for example: “C:\\temp\\”
Returns true on success, false on failure.
If one wishes to set other parameters in the driver, the included sample BiPlugin.dll must be modified.
Location of the DLL source code: <RTK Installation Folder>\<RTK 32/64 bit>\Samples\Sample Source Codes\C++\Plugin Output Dir C++ Sample
Compiling and Trying the Sample
The Plug-in (BiPlugin.dll) and BlackIceDEVMODE.dll component should be installed with the printer driver. The Plug-in (BiPlugin.dll) and BlackIceDEVMODE.dll component must be in the C:\windows\system32\ folder.
Open the Printing preferences; enable Start Application and select the compiled c# sample. Set the printer driver to start the application for Messaging.
NOTE: If the compiled C# sample is not specified in the Printer Driver Start Application, the BiPlugin.dll will time out to prevent print jobs getting stuck in the spooler. This timeout can be easily removed from the source code.
System support:
Windows 11/10/8/7 and Windows or Citrix Server 2022/2019/2016/2012 R2
The Plug-in sample application supports both 32 bit and 64 bit printer drivers.
Sample Source Code Folder Location:
<RTK Installation Folder>\<RTK 32/64 bit>\Samples\Sample Source Codes\C++\Plugin Output Dir C++ Sample
Solution files |
Compilers |
BiPlugin.dll: Plugin Output Dir C++ Sample_VS2015.sln Sample App: Plugin Output Dir C# Sample_VS2015.sln |
Visual Studio 2015 |
BiPlugin.dll: Plugin Output Dir C++ Sample_VS2017.sln Sample App: Plugin Output Dir C# Sample_VS2017.sln |
Visual Studio 2017 |
BiPlugin.dll: Plugin Output Dir C++ Sample_VS2019.sln Sample App: Plugin Output Dir C# Sample_VS2019.sln |
Visual Studio 2019 |
BiPlugin.dll: Plugin Output Dir C++ Sample_VS2022.sln Sample App: Plugin Output Dir C# Sample_VS2022.sln |
Visual Studio 2022 |