procedure ChangePrinterBin(ToBin: Integer);
var
ADevice, ADriver, APort: array [0..255] of Char;
DeviceHandle: THandle;
DevMode: PDeviceMode; // A Pointer to a TDeviceMode structure
begin
{ First obtain a handle to the TPrinter's DeviceMode structure }
Printer.GetPrinter(ADevice, ADriver, APort, DeviceHandle);
{ If DeviceHandle is still 0, then the driver was not loaded. Set
the printer index to force the printer driver to load making the
handle available }
if DeviceHandle = 0 then
begin
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(ADevice, ADriver, APort, DeviceHandle);
end;
{ If DeviceHandle is still 0, then an error has occurred. Otherwise,
use GlobalLock() to get a pointer to the TDeviceMode structure }
if DeviceHandle = 0 then
Raise Exception.Create('Could Not Initialize TDeviceMode
structure')
else
DevMode := GlobalLock(DeviceHandle);
with DevMode^ do
begin
dmFields := DM_DEFAULTSOURCE;
dmDefaultSource := ToBin;
end;
if not DeviceHandle = 0 then
GlobalUnlock(DeviceHandle);
end;
http://www.efg2.com/Lab/Library/UseNet/1999/1102.txt 에서가져왔습니다.
procedure ChangePrinterBin(ToBin: Integer);
var
ADevice, ADriver, APort: array [0..255] of Char;
DeviceHandle: THandle;
DevMode: PDeviceMode; // A Pointer to a TDeviceMode structure
begin
{ First obtain a handle to the TPrinter's DeviceMode structure }
Printer.GetPrinter(ADevice, ADriver, APort, DeviceHandle);
{ If DeviceHandle is still 0, then the driver was not loaded. Set
the printer index to force the printer driver to load making the
handle available }
if DeviceHandle = 0 then
begin
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(ADevice, ADriver, APort, DeviceHandle);
end;
{ If DeviceHandle is still 0, then an error has occurred. Otherwise,
use GlobalLock() to get a pointer to the TDeviceMode structure }
if DeviceHandle = 0 then
Raise Exception.Create('Could Not Initialize TDeviceMode
structure')
else
DevMode := GlobalLock(DeviceHandle);
with DevMode^ do
begin
dmFields := DM_DEFAULTSOURCE;
dmDefaultSource := ToBin;
end;
if not DeviceHandle = 0 then
GlobalUnlock(DeviceHandle);
end;