1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
PRINTER_INFO_2 *GetInfosPrn(char *szprn)
{
DWORD cbBuf=0;
DWORD cbNeeded=1000;
HANDLE hPrinter;
PRINTER_INFO_2 *pInfos=NULL;
// load printer driver
if(OpenPrinter(szprn,&hPrinter,NULL))
{
GetPrinter(
hPrinter, // handle to printer of interest
2, // version of printer info data structure
NULL, // pointer to array of bytes that receives printer info. structure
cbBuf, // size, in bytes, of array of bytes
&cbNeeded // pointer to variable with count of bytes retrieved (or required)
);
cbBuf=cbNeeded;
pInfos=(PRINTER_INFO_2 *)malloc(cbNeeded);
if(pInfos)
{
if(GetPrinter(hPrinter,2,(LPBYTE)pInfos,cbBuf,&cbNeeded))
{
}
else
{
free(pInfos);
ClosePrinter(hPrinter);
return(NULL);
}
}
ClosePrinter(hPrinter);
}
return(pInfos);
} |
Partager