Link to home
Start Free TrialLog in
Avatar of joepezt
joepezt

asked on

Opening printer queus, managing printer queues

hi!

I am looking for a way to open my printer queue from delphi. same as opening the printer from explorer...


also looking for a way to manage printerqueu from my own application... i.e. see the queue.. and delete from a specified printer
ASKER CERTIFIED SOLUTION
Avatar of twinsoft
twinsoft
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of joepezt
joepezt

ASKER

wow really, this is usefull too, if you can figure out how to also open my printer in explorer I double points :-)
What do you mean ?

"how to also open my printer in explorer"
Avatar of joepezt

ASKER

in explorer, you can go to printers, there you see all the installed printers.. you double click on it, and can open the queue from there also..

I just want to open this programmically
Hi, call this function with the name on the printer...

And please give some more points. As you can see from other threads, a question like this gets at least 500 points....

Uses ShlObj, ActiveX, ShellAPI;

function TForm1.OpenThisPrinter(PrinterName: String): Boolean;
var
 Allocator: IMalloc;
 PrinterItemIDList:  pItemIDList;
 ShellExecuteInfo :  TShellExecuteInfo;
begin
 Result := False;
 if CoGetMalloc(MEMCTX_TASK, Allocator) = S_OK then
  begin
   PrinterItemIDList := GetThisPrinter(PrinterName, Allocator);
   try
    if PrinterItemIDList = nil then
     Result := False
    else
     begin
      ZeroMemory(@ShellExecuteInfo, SizeOf(TShellExecuteInfo));
      with ShellExecuteInfo do
       begin
        cbSize := SizeOf(TShellExecuteInfo);
        fMask := SEE_MASK_INVOKEIDLIST OR SEE_MASK_FLAG_NO_UI;
        lpIDList := PrinterItemIDlist;
        nShow := SW_SHOWDEFAULT;
       end;

      ShellExecuteEx(@ShellExecuteInfo);
      Result := True;
     end;
   finally
    Allocator.Free(PrinterItemIDList)
   end;
  end;
end;