Question

As per the suggestion for the previous question I am trying to use the GetDefaultPrinter() and then to the CreateDC(), but the VC6 is consistently saying

error C2065: 'GetDefaultPrinter' : undeclared identifier

I tried Google but many faced the same problem, but none of them were fruitful. Is this a correct way to use the GetDefaultPrinter().

Winspool.h and Windows.h are included.

Was it helpful?

Solution

You probably have a very old SDK. Check if GetDefaultPrinter is defined in your winspool.h file. If not, here are the definitions:

BOOL
WINAPI
GetDefaultPrinterA (
    LPSTR pszBuffer,
    LPDWORD pcchBuffer
    );
BOOL
WINAPI
GetDefaultPrinterW (
    LPWSTR pszBuffer,
    LPDWORD pcchBuffer
    );
#ifdef UNICODE
#define GetDefaultPrinter  GetDefaultPrinterW
#else
#define GetDefaultPrinter  GetDefaultPrinterA
#endif // !UNICODE

BOOL
WINAPI
SetDefaultPrinterA (
    LPCSTR pszPrinter
    );
BOOL
WINAPI
SetDefaultPrinterW (
    LPCWSTR pszPrinter
    );
#ifdef UNICODE
#define SetDefaultPrinter  SetDefaultPrinterW
#else
#define SetDefaultPrinter  SetDefaultPrinterA
#endif // !UNICODE
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top