B
blues hu
Unregistered / Unconfirmed
GUEST, unregistred user!
谁有控制针式打印机(链式)走纸的dll的源码.
以下是我凑的源代码,错误多多,还请各位指教.我的环境为delphi6.0+win2000
library setprint;
uses
Windows,
printers,
WinSpool,
SysUtils,
Registry,
Classes;
function SetPaperSize(nWidth,nHeight,nOrient:word):integer;
var
ADevice,ADriver,APort:string;
ADeviceMode:THandle;
DevModeDeviceMode;
begin
setlength(adevice,255);
setlength(adriver,255);
setlength(aport,255);
if adevicemode=0 then
begin
printer.PrinterIndex :=printer.PrinterIndex ;
printer.GetPrinter(pchar(adevice),pchar(adriver),pchar(aport),adevicemode);
end;
if adevicemode<>0 then
begin
devmode:=globallock(adevicemode);
devmode^.dmFields :=devmode^.dmFields or dm_copies;
devmode^.dmCopies :=1;
end;
with devmode^do
begin
case nOrient of
0: begin
devmode^.dmFields:=devmode^.dmFields or DM_ORIENTATION;
devmode^.dmOrientation:=DMORIENT_PORTRAIT;
end;
1: begin
devmode^.dmFields:=devmode^.dmFields or DM_ORIENTATION;
devmode^.dmOrientation:=DMORIENT_LANDSCAPE;
end;
end;
devmode^.dmFields:=DM_PAPERSIZE or DM_PAPERWIDTH or DM_PAPERLENGTH;
devmode^.dmPaperSize:=DMPAPER_USER;
devmode^.dmPaperWidth:=nWidth;
devmode^.dmPaperLength:=nHeight;
end;
globalunlock(adevicemode);
globalfree(adevicemode);
closeprinter(adevicemode);
result:=1;
end;
exports
SetPaperSize;
{$R *.res}
begin
end.
以下是我凑的源代码,错误多多,还请各位指教.我的环境为delphi6.0+win2000
library setprint;
uses
Windows,
printers,
WinSpool,
SysUtils,
Registry,
Classes;
function SetPaperSize(nWidth,nHeight,nOrient:word):integer;
var
ADevice,ADriver,APort:string;
ADeviceMode:THandle;
DevModeDeviceMode;
begin
setlength(adevice,255);
setlength(adriver,255);
setlength(aport,255);
if adevicemode=0 then
begin
printer.PrinterIndex :=printer.PrinterIndex ;
printer.GetPrinter(pchar(adevice),pchar(adriver),pchar(aport),adevicemode);
end;
if adevicemode<>0 then
begin
devmode:=globallock(adevicemode);
devmode^.dmFields :=devmode^.dmFields or dm_copies;
devmode^.dmCopies :=1;
end;
with devmode^do
begin
case nOrient of
0: begin
devmode^.dmFields:=devmode^.dmFields or DM_ORIENTATION;
devmode^.dmOrientation:=DMORIENT_PORTRAIT;
end;
1: begin
devmode^.dmFields:=devmode^.dmFields or DM_ORIENTATION;
devmode^.dmOrientation:=DMORIENT_LANDSCAPE;
end;
end;
devmode^.dmFields:=DM_PAPERSIZE or DM_PAPERWIDTH or DM_PAPERLENGTH;
devmode^.dmPaperSize:=DMPAPER_USER;
devmode^.dmPaperWidth:=nWidth;
devmode^.dmPaperLength:=nHeight;
end;
globalunlock(adevicemode);
globalfree(adevicemode);
closeprinter(adevicemode);
result:=1;
end;
exports
SetPaperSize;
{$R *.res}
begin
end.