Using the Messaging Interface ID in the Printer Driver

The Messaging Interface ID of the Printer Driver is stored in the BlackIceDEVMODE structure. For more information about how to get or change the Printer Driver settings, including the Messaging Interface ID, please see the following pages:

 

How printers store their settings on Windows

 

Changing Printer Driver Settings Programmatically

 

Examples for changing the Printer Driver Messaging Interface ID:

 

Using the Printer Driver’s INI file:

 

1.    Locate the Printer Driver INI files (please note there are two of them and both have to be modified). For more information please refer to The Printer Driver INI filessection.

2.    Modify the Messaging Interface ID (SessionID flag in the INI file) value and/or the UseWindowsSessionID value in the [Default Settings] section and save your changes. For more information about Messaging Interface ID settings please see the Description of the INI file valuessection.

3.    Open Control Panel > Devices and Printers > right click on the Black Ice Printer, select “Printing Preferences”, click “Restore Defaults” and close the preferences by clicking OK.

If the API is used, The ReplaceUserSettings function reloads the INI file configuration to the printer driver.

If MSI installer is used, in the custom action section, after INI file is modified, the ReplaceUserSettings function loads the modified INI file configuration.

 

 

Using the BlackIceDEVMODE.dll or ocx:

 

1.    Call LoadBlackIceDEVMODE to get a handle to the BlackIceDEVMODE structure.

2.    Call GetSessionID, SetSessionID and/or IsUsingWindowsSessionID, SetUseWindowsSessionID to change the value.

3.    If SetSessionID or SetUseWindowsSessionID was called in the previous step, call SaveBlackIceDEVMODE to save your modified BlackIceDEVMODE structure for the current user.

4.    Call ReleaseBlackIceDEVMODE to free the used memory. (This is needed even if you use a programming language that uses a Garbage Collector, like C# or VB.NET)

 

For Printer Drivers earlier than 14.33, when printing directly using GDI the Messaging Interface ID can also be specified in the DEVMODE structure passed to CreateDC. This way a Message Interface ID can be unique to a print job or the application doing the printing.

 

For Printer Drivers 14.33 or later, the Message Interface ID is stored in the User’s registry, instead of the DEVMODE structure. The reason for this change is that some applications (like Microsoft Office) may store and use their own copy of the DEVMODE structure, overwriting the Message Interface ID with a wrong value. If the application needs to set a unique ID for the print job, it must set the Message Interface ID using the SetSessionID API function before printing and make sure the ID stays the same until the spooling starts. After the spooling started, the ID can be changed back, or changed to another value without affecting the print job. If necessary, a global mutex can be used by the application to synchronize the access.