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.

有帮助吗?

解决方案

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top