没人理我还是这里根本就没有大侠!

解决方案 »

  1.   

    这里就真没人知道这个东西吗?
    ?????????????
      

  2.   

    编了一个例子,调试通过:
    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.