F
fisher2003
Unregistered / Unconfirmed
GUEST, unregistred user!
//请问各位这个过程错在哪?
我想通过该过程获得打印机队列中的打印机名!
procedure TForm1.Button2Click(Sender: TObject);
var
//longbuffer: array of LongInt;
printInfo: array[0..50] of PRINTER_INFO_2;
pInfo: PRINTER_INFO_2;
numbytes,numneeded,numprinters: DWord;
c: integer;
retval: longbool;
retstr: array[0..255] of char;
begin
numneeded:= 0;
numprinters:= 0;
retval:= EnumPrinters(PRINTER_ENUM_LOCAL,nil,2,@printInfo,51*(sizeof(PRINTER_INFO_2)),numneeded,numprinters);
if not retval then
begin
numbytes:= numneeded;
showmessage(inttostr(numbytes));
retval:= Enumprinters(PRINTER_ENUM_LOCAL,nil,2,@printInfo,numbytes,numneeded,numprinters);
if not retval then
begin
showmessage('Could not Successfully enumerate the Printers');
Exit;
end;
end;
for c:= 0 to numprinters-1do
begin
try
pInfo:= printInfo[c];
retstr:= '';
strCopy(retstr,pInfo.pPrinterName);
showmessage(retstr);
memo1.Text:= memo1.Text + #13#10+retstr;
except
exit;
end;
end;
end;
我想通过该过程获得打印机队列中的打印机名!
procedure TForm1.Button2Click(Sender: TObject);
var
//longbuffer: array of LongInt;
printInfo: array[0..50] of PRINTER_INFO_2;
pInfo: PRINTER_INFO_2;
numbytes,numneeded,numprinters: DWord;
c: integer;
retval: longbool;
retstr: array[0..255] of char;
begin
numneeded:= 0;
numprinters:= 0;
retval:= EnumPrinters(PRINTER_ENUM_LOCAL,nil,2,@printInfo,51*(sizeof(PRINTER_INFO_2)),numneeded,numprinters);
if not retval then
begin
numbytes:= numneeded;
showmessage(inttostr(numbytes));
retval:= Enumprinters(PRINTER_ENUM_LOCAL,nil,2,@printInfo,numbytes,numneeded,numprinters);
if not retval then
begin
showmessage('Could not Successfully enumerate the Printers');
Exit;
end;
end;
for c:= 0 to numprinters-1do
begin
try
pInfo:= printInfo[c];
retstr:= '';
strCopy(retstr,pInfo.pPrinterName);
showmessage(retstr);
memo1.Text:= memo1.Text + #13#10+retstr;
except
exit;
end;
end;
end;