The IOCTL_USBPRINT_GET_LPT_STATUS request allows upper-layer software (such as a language monitor), to request and obtain the printer status byte from a USB printer.

To perform this operation, call the DeviceIoControl function with the following parameters.

bRet = DeviceIoControl(
    (HANDLE)  hDevice, 
    NULL, // lpInBuffer
    0, // nInBufferSize
    (PUCHAR)  lpOutBuffer,
    (DWORD)  nOutBufferSize, 
    (LPDWORD)  lpBytesReturned,
    (LPOVERLAPPED)  lpOverlapped 



The handle to the print device.


The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it. Use IOCTL_USBPRINT_GET_LPT_STATUS for this operation.


Not used in this operation; set this parameter to NULL. A pointer to a UCHAR input buffer.


Not used in this operation; set this parameter to 0. The size of the input buffer, in bytes.


A pointer to the output buffer, which consists of UCHAR data. On success this buffer holds the following: a two-byte prefix that specifies the size, in bytes, of the device's IEEE 1284 device ID; the device ID; and a null terminator. An IEEE 1284 device ID can be up to 64 KB in size. On failure, if GetLastError (described in the Windows SDK documentation) returns the error code ERROR_FILE_NOT_FOUND, this buffer contains the value BATTERY_TAG_INVALID.


The size of the output buffer, in bytes.


A pointer to a variable that receives the size of the data stored in the lpOutBuffer buffer, in bytes.

If the output buffer is too small to return any data then the call fails, GetLastError returns the error code ERROR_INSUFFICIENT_BUFFER, and the returned byte count is zero.

If lpOverlapped is NULL (nonoverlapped I/O), lpBytesReturned cannot be NULL. If lpOverlapped is not NULL (overlapped I/O), lpBytesReturned can be NULL. If this is an overlapped operation, you can retrieve the number of bytes returned by calling the GetOverlappedResult function. If hDevice is associated with an I/O completion port, you can get the number of bytes returned by calling the GetQueuedCompletionStatus function. GetOverlappedResult and GetQueuedCompletionStatus are described in the Windows SDK documentation.


A pointer to an OVERLAPPED structure (described in the Windows SDK documentation).

If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, lpOverlapped must point to a valid OVERLAPPED structure. In this case, DeviceIoControl is performed as an overlapped (asynchronous) operation. If the device was opened with the FILE_FLAG_OVERLAPPED flag and lpOverlapped is NULL, the function fails in unpredictable ways.

If hDevice was opened without specifying the FILE_FLAG_OVERLAPPED flag, lpOverlapped is ignored and the DeviceIoControl function does not return until the operation has been completed, or until an error occurs.

Return Value

If the operation succeeds, DeviceIoControl returns a nonzero value.

If the operation fails, DeviceIoControl returns zero. To get extended error information, call GetLastError.


To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the driver associated with a device. To specify a device name, use the following format:


DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to open handles to the physical drives on a system.


Declared in usbprint.h. Include usbprint.h.



Send comments about this topic to Microsoft