GetDefaultPrinter
The GetDefaultPrinter function retrieves the printer name of the default printer for the current user on the local computer.
BOOL GetDefaultPrinter(
LPTSTR pszBuffer, // printer name buffer
LPDWORD pcchBuffer // size of name buffer
);
Parameters
pszBuffer
[in] Pointer to a buffer that receives a null-terminated character string containing the default printer name. If this parameter is NULL, the function fails and the variable pointed to by pcchBuffer returns the required buffer size, in characters.
pcchBuffer
[in/out] On input, specifies the size, in characters, of the pszBuffer buffer. On output, receives the size, in characters, of the printer name string, including the terminating null character.
Return Values
If the function succeeds, the return value is a nonzero value and the variable pointed to by pcchBuffer contains the number of characters copied to the pszBuffer buffer, including the terminating null character.
If the function fails, the return value is zero. To get extended error information, call GetLastError, which can return one of the following error codes.