Y
yeo
Unregistered / Unconfirmed
GUEST, unregistred user!
请帮忙解决以下问题:
以下是程序段:
procedure prns(PrinterName:String;
S:String);
var
Handle: THandle;
N: DWORD;
do
cInfo1: TDocInfo;
pDocName : PChar;
pOutputFile : PChar;
pDataType : PChar;
begin
if not OpenPrinter(PChar(PrinterName), Handle, 0) then
begin
ShowMessage('error' + IntToStr(GetLastError));
Exit;
end;
withdo
cInfo1do
begin
pDocName:=PChar('testdo
c');
pOutputFile:=PChar(s);
pDataType:='RAW';
end;
if StartDocPrinter(Handle,1,@DocInfo1)=0 //问题就在这里
then
showmessage('startdo
c');
StartPagePrinter(Handle);
WritePrinter(Handle,PChar(S),Length(S),N);
EndPagePrinter(Handle);
EndDocPrinter(Handle);
ClosePrinter(Handle);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
prns('Epson LQ-1600K','A');
问题:
1、当StartDocPrinter(Handle,1 这里为1运行就会出现以下错误:
Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address 72F7AD86 in module 'winspool.drv'. Read of address 00000025'.
当设置为其他数值就没有此出错问题,但是返回值总是0(在API说明中,Level数值用于win95,为什么此处设置为1会有不一样?我的系统是xp)
2、对于StartDocPrinter函数,这里的pDocInfo具体该如何设置?(由于程序是参考别人的),看API说明,这里是缓冲区设置,什么意思??
以下是程序段:
procedure prns(PrinterName:String;
S:String);
var
Handle: THandle;
N: DWORD;
do
cInfo1: TDocInfo;
pDocName : PChar;
pOutputFile : PChar;
pDataType : PChar;
begin
if not OpenPrinter(PChar(PrinterName), Handle, 0) then
begin
ShowMessage('error' + IntToStr(GetLastError));
Exit;
end;
withdo
cInfo1do
begin
pDocName:=PChar('testdo
c');
pOutputFile:=PChar(s);
pDataType:='RAW';
end;
if StartDocPrinter(Handle,1,@DocInfo1)=0 //问题就在这里
then
showmessage('startdo
c');
StartPagePrinter(Handle);
WritePrinter(Handle,PChar(S),Length(S),N);
EndPagePrinter(Handle);
EndDocPrinter(Handle);
ClosePrinter(Handle);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
prns('Epson LQ-1600K','A');
问题:
1、当StartDocPrinter(Handle,1 这里为1运行就会出现以下错误:
Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address 72F7AD86 in module 'winspool.drv'. Read of address 00000025'.
当设置为其他数值就没有此出错问题,但是返回值总是0(在API说明中,Level数值用于win95,为什么此处设置为1会有不一样?我的系统是xp)
2、对于StartDocPrinter函数,这里的pDocInfo具体该如何设置?(由于程序是参考别人的),看API说明,这里是缓冲区设置,什么意思??