该出手时就出手!大侠,你知道如何后台监测打印机吗? 没人理我还是这里根本就没有大侠! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这里就真没人知道这个东西吗?????????????? 编了一个例子,调试通过:unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls;type TForm1 = class(TForm) Button1: TButton; ListBox1: TListBox; ListBox2: TListBox; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM}uses printers, winspool;procedure TForm1.FormCreate(Sender: TObject);begin ListBox1.Items.Assign(Printer.Printers); ListBox1.ItemIndex := 0;end;procedure TForm1.Button1Click(Sender: TObject);Var jobinfo2, p : PJobInfo2; cbNeeded, cReturned : Longword; hPrinter : THandle; Device, Driver, Port : array [0..100] Of Char; i : Integer;begin Printer.PrinterIndex := ListBox1.ItemIndex; Printer.GetPrinter( PChar(@Device), PChar(@Driver), PChar(@Port), hPrinter); OpenPrinter( Device, hPrinter, nil ); Try EnumJobs( hPrinter, 0, $ffffffff, 2, nil, 0, cbNeeded, cReturned ); If cbNeeded > 0 Then Begin GetMem(jobinfo2, cbNeeded ); Try If EnumJobs( hPrinter, 0, $ffffffff, 2, jobinfo2, cbNeeded, cbNeeded, cReturned ) Then For i := 0 To cReturned-1 Do Begin p := PJobInfo2(PChar(jobinfo2) + i*SizeOf( TJobInfo2 )); With p^ Do ListBox2.Items.Add( Format( 'UserName :%s, Document:%s', [pUserName, pDocument]) ); End; Finally FreeMem( jobInfo2 ); End End; Finally ClosePrinter( hPrinter ); End;end;end. 求助,二进制数据的转换问题 StringGrid中單元格編輯狀態的問題 大家来评评理,发泄一下吧,来者有分! 我在用PDU 7位V发送短信时,什么会有乱码出现啊?什么原因?? 怎么删除我在DBGrid1中选中的记录? 如何得到共享文件的密码 !!!!巨好消息!!!!Delphi 6有了中文版了!!!!!! 怎样利用TADOStoredProc 来获取记录集!!! 同志们,请教对于文件的操作 !!! Delphi中有缺省参数吗,怎么处理这些缺省参数?十分火急!一定给分! 登陆窗体呀 dana(dana):来这拿分
?????????????
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls;type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
ListBox2: TListBox;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}uses printers, winspool;procedure TForm1.FormCreate(Sender: TObject);
begin
ListBox1.Items.Assign(Printer.Printers);
ListBox1.ItemIndex := 0;
end;procedure TForm1.Button1Click(Sender: TObject);
Var jobinfo2, p : PJobInfo2;
cbNeeded, cReturned : Longword;
hPrinter : THandle;
Device, Driver, Port : array [0..100] Of Char;
i : Integer;
begin
Printer.PrinterIndex := ListBox1.ItemIndex;
Printer.GetPrinter( PChar(@Device), PChar(@Driver), PChar(@Port), hPrinter);
OpenPrinter( Device, hPrinter, nil );
Try
EnumJobs( hPrinter, 0, $ffffffff, 2, nil, 0, cbNeeded, cReturned );
If cbNeeded > 0 Then
Begin
GetMem(jobinfo2, cbNeeded );
Try
If EnumJobs( hPrinter, 0, $ffffffff, 2, jobinfo2, cbNeeded, cbNeeded, cReturned ) Then
For i := 0 To cReturned-1 Do
Begin
p := PJobInfo2(PChar(jobinfo2) + i*SizeOf( TJobInfo2 ));
With p^ Do
ListBox2.Items.Add( Format( 'UserName :%s, Document:%s', [pUserName, pDocument]) );
End;
Finally
FreeMem( jobInfo2 );
End
End;
Finally
ClosePrinter( hPrinter );
End;
end;end.