I'm working my way through Petzold's Prtogramming Windows 5th edition and have run into a snag. I'm hoping one of you gurus might be able to explain what it is I'm doing that is a no-no.
first the code:
Code:
#include
HDC GetPrintDC (void)
{
DWORD dwNeeded, dwReturned;
HDC hdc;
PRINTER_INFO_4 * pinfo4;
PRINTER_INFO_5 * pinfo5;
if (GetVersion() & 0x80000000)
{
EnumPrinters (PRINTER_ENUM_DEFAULT, NULL, 5, NULL, 0, &dwNeeded, &dwReturned);
pinfo5= malloc (dwNeeded);
EnumPrinters (PRINTER_ENUM_DEFAULT, NULL, 5, (PBYTE) pinfo5, dwNeeded, &dwNeeded, &dwReturned);
hdc=CreateDC (NULL, pinfo5->pPrinterName,NULL, NULL);
free (pinfo5);
}
else
{
EnumPrinters (PRINTER_ENUM_LOCAL, NULL, 4, NULL, 0, &dwNeeded, &dwReturned);
pinfo4= malloc (dwNeeded);
EnumPrinters (PRINTER_ENUM_LOCAL, NULL, 4, (PBYTE) pinfo4, dwNeeded, &dwNeeded, &dwReturned);
hdc= CreateDC (NULL, pinfo4->pPrinterName, NULL, NULL);
free(pinfo4);
}
return hdc;
}
And now the error message:
Code:
--------------------Configuration: GETPRNDC - Win32 Debug--------------------
Compiling...
GETPRNDC.CPP
F:\Games\Fire\GETPRNDC\GETPRNDC.CPP(14) : error C2440: '=' : cannot convert from 'void *' to 'struct _PRINTER_INFO_5A *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
F:\Games\Fire\GETPRNDC\GETPRNDC.CPP(26) : error C2440: '=' : cannot convert from 'void *' to 'struct _PRINTER_INFO_4A *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
Error executing cl.exe.
GETPRNDC.OBJ - 2 error(s), 0 warning(s)
I hope no one minds me posting this here. I fugure it's my best chance of getting an explanation.
Thanks all.
Best,
Jerry