Printers_RegisterWindowW

Go to Home Page

Registers the StubWindow32 window class and creates an invisible top-level window associated with a printers pidl.

Syntax

BOOL WINAPI Printers_RegisterWindowW (
    LPCWSTR pwszPrinter,
    DWORD pidlType,
    BOOL* pWinCreated,
    HWND* phwnd
)

Parameters

pwszPrinter
The name of the printer
pidlType
Unused
pWinCreated
Pointer to a BOOL that indicates whether a window was created
phwnd
Pointer to a HWND that receives the handle to the created window

Return Value

Returns TRUE if the printers pidl or that of CSIDL_PRINTERS could be retrieved, FALSE otherwise.

Remarks

If a window of class StubWindow32 exists for the printer, the original window is brought to the foreground, no new window is created. phwnd receives NULL and pWinCreated receives FALSE.

On XP, the prototype is


BOOL WINAPI Printer_RegisterWindowW(LPCWSTR name, DWORD flags, CLASSPIDL* pClassPidl, HWND* pHwnd)

where CLASSPIDL (named from asserts in printui.dll chk build) is defined as

struct CLASSPIDL
{
    HWND hwnd; // the invisible StubWindow32 window, same as *pHwnd
    HANDLE hData; // use SHLockShared(hData, 0) to get a pointer
    HICON hPrinterIcon; // from SHGetFileInfo
};

The CLASSPIDL structure must be freed by Printers_UnregisterWindow when you've finished with it and the window.

Locking the hData handle returns a pointer to another struct

struct PRINTERID
{
    int unknown; // always 1
    ITEMIDLIST printerPidl; // have a guess
};

On 7, you can get the CLASSPIDL::hData by calling GetWindowLongPtr(*phwnd, 0). You must still use SHLockShared to get a pointer.

CoInitialize/CoInitializeEx is required before calling the function on XP

printui.dll uses the returned window as parent for printer property sheets

This function is also known as _Printers_RegisterWindowW@16