Overview

Since some of the settings of the PDF printer are global in the registry, we need to synchronize access to them when dealing with printing from multiple processes or threads.

The Lock/Unlock methods accomplish this by instructing the spooler to get the settings per job, by its job name.

 

The Unlock time-out value should be very large, to give enough time for the job to finish printing. Even if unlock was not called, the print spooler unlocks the reserved area as soon as it retrieves the needed settings from it.

 

In case of 2 print jobs having the same job name, they are serialized, one after the other.

 

Other than that, print jobs can ran simultaneously, each taking its settings from its public reserved area.

 

For the Lock/Unlock to work as expected, the return value should be checked.

 

The return error codes of the Lock function are as follows:

 

Return value description

Value

Success

0

Cannot read\write to the registry key: HKEY_LOCAL_MACHINE\Software\[printer name]\Locks

-1

Failed

<-1