AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Drucker Warteschlange leeren?

Ein Thema von chris01 · begonnen am 25. Apr 2004 · letzter Beitrag vom 6. Mai 2006
Antwort Antwort
chris01

Registriert seit: 26. Apr 2003
Ort: Ahlen
163 Beiträge
 
Delphi 7 Personal
 
#1

Drucker Warteschlange leeren?

  Alt 25. Apr 2004, 20:04
Hi,

gibt es eine API-Funktion, die die Warteschlange des Druckers leert? Ich hab bis jetzt nur im SwissDelphiCenter eine Funktion zum Auslesen dieser gefunden.

Diese hier...

Gruß
Christopher
Christopher H.
  Mit Zitat antworten Zitat
Assarbad
(Gast)

n/a Beiträge
 
#2

Re: Drucker Warteschlange leeren?

  Alt 27. Apr 2004, 13:31
Nein, es gibt nicht EINE Funktion. Du mußt die Jobs mit EnumJobs() listen und dann mit:

Code:
BOOL SetJob(
  HANDLE hPrinter, // handle to printer object
  DWORD JobId,     // print job identifier
  DWORD Level,     // information level
  LPBYTE pJob,    // job information buffer
  DWORD Command    // job command value
);
... abbrechen
  Mit Zitat antworten Zitat
norbertd

Registriert seit: 5. Mai 2006
5 Beiträge
 
#3

Re: Drucker Warteschlange leeren?

  Alt 6. Mai 2006, 00:44
Hiermit geht es:

Delphi-Quellcode:
// start service
//
// return TRUE if successful
//
// sMachine:
// machine name, ie: \\SERVER
// empty = local machine
//
// sService
// service name, ie: spooler
//
function TPPInstallForm.ServiceStart(sMachine, sService : string ) : boolean;
  var
    schm, schs : SC_Handle; // service control manager handle & service handle
    ss : TServiceStatus; // service status
    psTemp : PChar; // temp char pointer
    dwChkP : DWord; // check point
  begin
    ss.dwCurrentState := 0;
    // connect to the service control manager
    schm := OpenSCManager(PChar(sMachine), Nil, SC_MANAGER_CONNECT);
    // if successful...
    if(schm > 0)then begin
      // open a handle to the specified service
      // we want to start the service and query service status
      schs := OpenService(schm, PChar(sService), SERVICE_START or SERVICE_QUERY_STATUS);
      // if successful...
      if(schs > 0)then begin
        psTemp := Nil;
        if(StartService(schs, 0, psTemp)) then begin
          // check status
          if (QueryServiceStatus(schs, ss))then begin
            while (SERVICE_RUNNING <> ss.dwCurrentState)do begin
              //
              // dwCheckPoint contains a value that the service increments periodically
              // to report its progress during a lengthy operation.
              // save current value
              dwChkP := ss.dwCheckPoint;
              // wait a bit before checking status again
              //
              // dwWaitHint is the estimated amount of time
              // the calling program should wait before calling
              // QueryServiceStatus() again
              //
              // idle events should be
              // handled here...
              //
              Sleep(ss.dwWaitHint);
              if (not QueryServiceStatus(schs, ss))then begin
                // couldn't check status
                // break from the loop
                break;
              end;
              if (ss.dwCheckPoint < dwChkP) then begin
                // QueryServiceStatus didn't increment dwCheckPoint as it should have.
                // avoid an infinite loop by breaking
                break;
              end;
            end;
          end;
        end;
        // close service handle
        CloseServiceHandle(schs);
      end;
      // close service control manager handle
      CloseServiceHandle(schm);
  end;
  // return TRUE if the service status is running
  Result := SERVICE_RUNNING = ss.dwCurrentState;
end;

//------------------------------------------------------------------------------
// stop service
//
// return TRUE if successful
//
// sMachine:
// machine name, ie: \\SERVER
// empty = local machine
//
// sService
// service name, ie: Alerter
//
function TPPInstallForm.ServiceStop(sMachine, sService : string ) : boolean;
  var
    schm, schs : SC_Handle; // service control & service handle manager handle
    ss : TServiceStatus; // service status
    dwChkP : DWord; // check point
  begin
    // connect to the service control manager
    schm := OpenSCManager(PChar(sMachine), Nil, SC_MANAGER_CONNECT);
    // if successful...
    if (schm > 0) then begin
      // open a handle to the specified service
      // we want to stop the service and query service status
      schs := OpenService(schm, PChar(sService), SERVICE_STOP or SERVICE_QUERY_STATUS);
      // if successful...
      if (schs > 0) then begin
        if (ControlService(schs, SERVICE_CONTROL_STOP, ss)) then begin
          // check status
          if (QueryServiceStatus(schs, ss)) then begin
            while (SERVICE_STOPPED <> ss.dwCurrentState) do begin
              // dwCheckPoint contains a value that the service increments periodically
              // to report its progress during a lengthy operation.
              // save current value
              dwChkP := ss.dwCheckPoint;
              // wait a bit before checking status again
              // dwWaitHint is the estimated amount of time
              // the calling program should wait before calling QueryServiceStatus() again
              // idle events should be handled here...
              Sleep(ss.dwWaitHint);
              if (not QueryServiceStatus(schs, ss)) then begin
                // couldn't check status
                // break from the loop
                break;
              end;
              if (ss.dwCheckPoint < dwChkP) then begin
                // QueryServiceStatus didn't increment dwCheckPoint as it should have.
                // avoid an infinite loop by breaking
                break;
              end;
            end;
          end;
        end;
        // close service handle
        CloseServiceHandle(schs);
      end;
      // close service control manager handle
      CloseServiceHandle(schm);
    end;
    // return TRUE if the service status is stopped
    Result := SERVICE_STOPPED = ss.dwCurrentState;
end;
...und hier die Einleitung für den eigentlichen Code:

Delphi-Quellcode:
      if (ServiceStop('', 'spooler')) then
         begin

      //Hier Deinen Code einfügen..............

      if not ServiceStart('', 'spooler') then
         ShowMessage('Der Spoolservice konnte nicht gestartet werden.' + #13 + 'Bitte den Treiber deinstallieren und wiederholen.')
[edit=Luckie]Delphi-Tags hinzugefügt. Mfg, Luckie[/edit]
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:32 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz