Link to home
Start Free TrialLog in
Avatar of wimmeyvaert
wimmeyvaert

asked on

Calling Start-Settings-Printers

Hi Experts,

Is there anyone who knows how to open Start-Settings-Printers from within a Delphi-application ?

I'm using D5, Win NT4 SP6.

Thanx,

The Mayor.
Avatar of wimmeyvaert
wimmeyvaert

ASKER

I found something on the net :

uses ShellApi, ShlObj;

procedure TForm1.Button1Click(Sender: TObject);
 var
    PIDL:PItemIDList;
    Info:TShellExecuteInfo;
    pInfo:PShellExecuteInfo;
    WaitCode:DWord;
 begin
    {Obtenemos PIDL de la carpeta virtual}
    {get PIDL of the virtual folder}
    SHGetSpecialFolderLocation(Handle,
                               CSIDL_PRINTERS,
                               PIDL);
    {Puntero a Info}
    {Pointer to Info}
    pInfo:=@Info;
    {Rellenamos Info}
    {Fill info}
    With Info do
    begin
     cbSize:=SizeOf(Info);
     fMask:=SEE_MASK_NOCLOSEPROCESS+
            SEE_MASK_IDLIST;
     wnd:=Handle;
     lpVerb:=nil;
     lpFile:=nil;
     {Parametros al ejecutable}
     {Executable parameters}
     lpParameters:=nil;
     lpDirectory:=nil;
     nShow:=SW_ShowNormal;
     hInstApp:=0;
     lpIDList:=PIDL;
    end;
    {Ejecutamos}
    {Execute}
    ShellExecuteEx(pInfo);

    {Esperamos que termine}
    {Wait to finish}
    repeat
     WaitCode := WaitForSingleObject(Info.hProcess,500);
     Application.ProcessMessages;
    until (WaitCode <> WAIT_TIMEOUT);

 end;


This does the trick!
But is there anyone who knows how to open the printerspooler from a speicific printer from within a Delphi-App ?

ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

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