으음 프린터 출력을 테스트 하고 있는데 에러가 나는군요
혹시 해결방법을 알고 계신 고수분이 계시면 도움을 부탁드립니다.
감사합니다.
---------------------------------------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, printers, winspool;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function PrintData( Data : String ): Boolean;
var
Prt : TPrinter;
ADevice, ADriver, APort : array[0..79] of Char;
ADeviceMode : THandle;
DocInfo : TDocInfo;
HPrt : THandle;
WriterCount : integer;
begin
Result := False;
Prt := Printer;
Prt.PrinterIndex := -1;
Prt.GetPrinter (ADevice, ADriver, APort, ADeviceMode);
if not OpenPrinter(ADevice, HPrt, nil) then
begin
Result := False;
Exit;
end;
if HPrt = 0 then
begin
Result := False;
Exit;
end;
// 여기에서 에러가 발생합니다.
if not WritePrinter(HPrt, PChar(Data), Length(Data), WriterCount) then begin
MessageBeep($ffff);
Result := False;
Exit;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
PrintData( '1234567890' );
end;
end.