bool SetSysPrinterPaperSize(
int PaperSize,
do
uble PaperLength,
do
uble PaperWidth)
{
_PRINTER_INFO_2A *PrinterInfo;
DWORD dwNeededSize = 1000;
HDC hPrinter = NULL;
String PrinterName = GetCurrentPrinterName();
if( PrinterName.IsEmpty()) return false;
OpenPrinter( PrinterName.c_str(),&hPrinter,NULL);
if( ! hPrinter) return false;
PrinterInfo = (_PRINTER_INFO_2A *)new char[ dwNeededSize];
if( ! GetPrinter( hPrinter, 2,
(LPBYTE)PrinterInfo, dwNeededSize, &dwNeededSize)) {
delete[] PrinterInfo;
PrinterInfo = (_PRINTER_INFO_2A *)new char[ dwNeededSize];
if( ! GetPrinter( hPrinter, 2,
(LPBYTE)PrinterInfo, dwNeededSize, &dwNeededSize))
return false;
}
PrinterInfo->pDevMode->dmPaperSize = PaperSize;
PrinterInfo->pDevMode->dmPaperLength = PaperLength;
PrinterInfo->pDevMode->dmPaperWidth = PaperWidth ;
PrinterInfo->pDevMode->dmFields = PrinterInfo->pDevMode->dmFields
| DM_PAPERSIZE | DM_PAPERLENGTH | DM_PAPERWIDTH ;
bool Ret = SetPrinter( hPrinter, 2, (LPBYTE)PrinterInfo, 0);
delete[] PrinterInfo;
ClosePrinter (hPrinter) ;
return Ret;
}