Pegar o nome do papel que está configurado na impressora
Alguem sabe como posso pega o tipo de papel que está configurado na impressora? pego o tamanho assim:
Printer.PageWidth;
Printer.PageHeight; mas alem disso gostaria de pegar o nome, consigo listar todos os papeis disponiveis mas não sei qual o que está configurado. Gostaria tambem de mudar o papel. igual o componente TSetupPrinter faz. Se alguem souber de algo, des de já muito grato,
Nelson Lima
Printer.PageWidth;
Printer.PageHeight; mas alem disso gostaria de pegar o nome, consigo listar todos os papeis disponiveis mas não sei qual o que está configurado. Gostaria tambem de mudar o papel. igual o componente TSetupPrinter faz. Se alguem souber de algo, des de já muito grato,
Nelson Lima
_nekinho_
Curtidas 0
Respostas
Aroldo Zanela
23/09/2003
Colega,
Peguei uma rotina (com um Bug - ainda não resolvido), vê se mata!.
Peguei uma rotina (com um Bug - ainda não resolvido), vê se mata!.
Hi,
how do i get the printer settings ??? like papersize etc.
I´ve tried this...
function GetCurrentPrinterHandle: THandle;
var
Device, Driver, Port : array[0..255] of char;
hDeviceMode: THandle;
begin
Printer.GetPrinter(Device, Driver, Port, hDeviceMode);
if not OpenPrinter(@Device, Result, nil) then
RaiseLastWin32Error;
end;
function GetCurrentPrinterInformation: TPrinterInfo;
var
hPrinter : THandle;
pInfo: PPrinterInfo2;
bytesNeeded: DWORD;
begin
hprinter := GetCurrentPrinterHandle;
try
Winspool.GetPrinter( hPrinter, 2, Nil, 0, @bytesNeeded );
pInfo := AllocMem( bytesNeeded );
try
Winspool.GetPrinter( hPrinter, 2, pInfo, bytesNeeded, @bytesNeeded );
Result.SeverName := pInfo^.pServerName;
Result.PrinterName := pInfo^.pPrinterName;
Result.ShareName := pInfo^.pShareName;
Result.PortName := pInfo^.pPortName;
Result.DriverName := pInfo^.pDriverName;
Result.Comment := pInfo^.pComment;
Result.Location := pInfo^.pLocation;
Result.DeviceMode := pInfo^.pDevMode;
Result.SepFile := pInfo^.pSepFile;
Result.PrintProcessor := pInfo^.pPrintProcessor;
Result.DataType := pInfo^.pDatatype;
Result.Parameters := pInfo^.pParameters;
Result.SecurityDescriptor := pInfo^.pSecurityDescriptor;
Result.Attributes := pInfo^.Attributes;
Result.DefaultPriority := pInfo^.DefaultPriority;
Result.StartTime := pInfo^.StartTime;
Result.UntilTime := pInfo^.UntilTime;
Result.Status := pInfo^.Status;
Result.Jobs := pInfo^.cJobs;
Result.AveragePPM := pInfo^.AveragePPM;
finally
FreeMem( pInfo );
end;
finally
ClosePrinter( hPrinter );
end;
end;
var
PrinterInfo: TPrinterInfo;
begin
Printer.PrinterIndex := ComboBox1.ItemIndex;
PrinterInfo := GetCurrentPrinterInformation;
memo1.Clear;
with memo1.Lines do
begin
Add(´GENERAL INFORMATION´);
Add(´´);
Add(´Status: ´ + IntToStr(PrinterInfo.Status));
Add(´Jobs: ´ + IntToStr(PrinterInfo.Jobs));
Add(´AveragePPM: ´ + IntToStr(PrinterInfo.AveragePPM));
Add(´´);
Add(´DEVICEMODE INFORMATION´);
Add(´´);
Add(´DeviceName: ´ + PrinterInfo.DeviceMode.dmDeviceName);
Add(´Orientation: ´ + IntToStr(PrinterInfo.DeviceMode.dmOrientation));
Add(´PaperSize: ´ + IntToStr(PrinterInfo.DeviceMode.dmPaperSize));
Add(´PaperLength: ´ + IntToStr(PrinterInfo.DeviceMode.dmPaperLength));
Add(´PaperWidth: ´ + IntToStr(PrinterInfo.DeviceMode.dmPaperWidth));
end;
end;
But it doesn´t give me the actual configuration of the printer.. It gives me
tha config that was. Ie.
My printer settings is set to : Paper: A4
I Change to : A5
Check with my little routine and it tells me the size is A4.
I Change to A4
Check with my little routine and it tells me the size is A5 ..
WTF.. It´s one step behind all the time.. Anyone got a solution ???
Rgrds, Falkesand
GOSTEI 0
_nekinho_
23/09/2003
Cara valeu acho q vai me ajudar sim. Vou dar uma analisada aqui e qualquer coisa te aviso, um forte abraço,
Nelson Lima
NecteK - ´Pensando diferente´
Nelson Lima
NecteK - ´Pensando diferente´
GOSTEI 0