Skip to content

LockPrinter

Description

Locks all data transmission and hardware reset requests from other processes to the printer.

Syntax

  
    INT LockPrinter( INT i_hdl, DWORD i_timeout )
  

Parameter

i_hdl

API handle
Specify the API handle retrieved by OpenMonPrinter.

i_timeout

Timeout period
Specify the time to wait for success of this API in milliseconds (ms).
The valid range is from 3000 to 90000.
When the value is specified less than 3000, the time is set to 3000 ms.
When the value is specified more than 90000, the time is set to 90000 ms.

Return value

On success: Returns 0.
On failure: Returns an error code. See "Error Code List" for details of the error code.

Remarks

    • When any APIs that directly access the printer are called from other processes during the time from calling this API until UnlockPrinter is called, those APIs fail.
    • Only other processes are locked by this API. Therefore, calls from the process itself are not locked regardless of API handles or threads.
    • By this API, multiple locking is possible up to 99 times with the same API handle. In order to release the lock, call UnlockPrinter the same number of times as for this API.
    • When LockPrinter is being called by another process, calling this API fails.