Dot로 바로 출력하는 부분인데 이상하게 WritePrinrer함수에서 에러가 납니다
좀 도와 주세요 참고로 저는 델파이4를 씁니다
Error 메세지는 (Types of actual and Fomal Var Parameters Must be Identical)입니다
type
TDocInfo = record
pDocName : PChar;
pOutputFile : PChar;
pDatatype : PChar;
end;
{$IFDEF Win32}
function TK_Sale_m2_18.PrintData( Data : String ): Boolean;
var
Prt : TPrinter;
ADevice, ADriver, APort : array[0..79] of Char;
ADeviceMode, HPrt : THandle;
DocInfo : TDocInfo;
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;
DocInfo.pDocName := 'Test Print';
DocInfo.pOutputFile := nil;
DocInfo.pDataType := 'RAW';
if StartDocPrinter(HPrt, 1, @DocInfo) = 0 then
begin
Result := False;
Exit;
end;
if not StartPagePrinter(HPrt) then
begin
Result := False;
Exit;
end;
//이부분에서 에러가 납니다
if not WritePrinter(HPrt, PChar(Data), Length(Data), WriterCount) then
begin
MessageBeep($ffff);
Result := False;
Exit;
end;
if not EndPagePrinter(HPrt) then
begin
Result := False;
Exit;
end;
if not EndDocPrinter(HPrt) then Exit;
ClosePrinter(HPrt);
end;
{$ENDIF}
그건 변수형이 안맞아서 그런것입니다.
아래와 같이 Cardinal형으로 형변환해주세요...
WritePrinter(HPrt, PChar(Data), Length(Data), DWORD(WriterCount));
^^ 항상 즐코하세요.
이승우 wrote:
> Dot로 바로 출력하는 부분인데 이상하게 WritePrinrer함수에서 에러가 납니다
> 좀 도와 주세요 참고로 저는 델파이4를 씁니다
> Error 메세지는 (Types of actual and Fomal Var Parameters Must be Identical)입니다
>
> type
> TDocInfo = record
> pDocName : PChar;
> pOutputFile : PChar;
> pDatatype : PChar;
> end;
>
> {$IFDEF Win32}
> function TK_Sale_m2_18.PrintData( Data : String ): Boolean;
> var
> Prt : TPrinter;
> ADevice, ADriver, APort : array[0..79] of Char;
> ADeviceMode, HPrt : THandle;
> DocInfo : TDocInfo;
> 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;
>
> DocInfo.pDocName := 'Test Print';
> DocInfo.pOutputFile := nil;
> DocInfo.pDataType := 'RAW';
>
> if StartDocPrinter(HPrt, 1, @DocInfo) = 0 then
> begin
> Result := False;
> Exit;
> end;
>
> if not StartPagePrinter(HPrt) then
> begin
> Result := False;
> Exit;
> end;
>
> //이부분에서 에러가 납니다
> if not WritePrinter(HPrt, PChar(Data), Length(Data), WriterCount) then
> begin
> MessageBeep($ffff);
> Result := False;
> Exit;
> end;
>
>
> if not EndPagePrinter(HPrt) then
> begin
> Result := False;
> Exit;
> end;
>
> if not EndDocPrinter(HPrt) then Exit;
>
> ClosePrinter(HPrt);
>
> end;
> {$ENDIF}
>