|
After I opened the handle obtained by OpenPrinter with GetPrinter, the status member in the PRINTER_INFO_2 structure could not find the error code "Unable to connect", but Windows 2003 itself can determine if a network printer is in the [Printers and Faxes] list due to network connection. Nowhere, "Unable to connect" will be displayed in the [Status] column. I don't know how Windows does it.
I guess that you may use OpenPrinter2, an undocumented API, and use the PRINTER_OPTIONS parameter to obtain a remote handle because there are the following options for PRINTER_OPTIONS in msdn
The PRINTER_OPTION_FLAGS enumeration is used to specify the caching of a handle for a printer opened with OpenPrinter2.
typedef enum
{
PRINTER_OPTION_NO_CACHE,
PRINTER_OPTION_CACHE,
PRINTER_OPTION_CLIENT_CHANGE
} PRINTER_OPTION_FLAGS;
PRINTER_OPTION_NO_CACHE
The handle is not cached. All functions applied to a handle returned by OpenPrinter2 will go to the remote computer.
PRINTER_OPTION_CACHE
The handle is cached. All functions applied to a handle returned by OpenPrinter2 will go to the local cache.
PRINTER_OPTION_CLIENT_CHANGE
The handle returned by OpenPrinter2 can be used by SetPrinter to rename the printer connection. |
|