Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Ändern des Printerstatus (https://www.delphipraxis.net/10265-aendern-des-printerstatus.html)

Matthias_H 14. Okt 2003 23:48


Ändern des Printerstatus
 
Wer kann mir helfen. Ich versuche eine Windows-Queue anzuhalten bzw. zu starten und verwende folgenden Code. Ich denke das sollte so funktionieren, erhalte aber "Zugriff verweigert" obwohl ich alle Rechte besitze.

Delphi-Quellcode:
function SetPrinterStatus(PrinterHandle:THandle;Status:integer):Boolean;
type
    TPrinterInfo=Printer_Info_2;
    PPrinterInfo=^TPrinterInfo;
var
    BytesNeeded:Cardinal;
    PInfo:PPrinterInfo;
begin
     Result:=false;
     GetPrinter(PrinterHandle,2,nil,0,@BytesNeeded);  //Speicherbedarf lesen
     PInfo:=AllocMem(BytesNeeded);
     //Daten holen
     if (GetPrinter(PrinterHandle,2,PInfo,BytesNeeded,@BytesNeeded)) then begin
         //Status schreiben
         Result:= Winspool.SetPrinter(PrinterHandle,0,PInfo,Status);      
         If not Result then
            ShowMessage(SysErrorMessage(GetLastError));
     end;
     FreeMem(PInfo);
end;

Procedure PausePrinter(QueueName:String);
var PrinterHandle:THandle;
begin
  If OpenPrinter(PChar(QueueName),PrinterHandle,nil) then begin
     SetPrinterStatus(PrinterHandle,PRINTER_CONTROL_PAUSE);
     ClosePrinter(PrinterHandle);
  end;
end;

Der Felertoifel 15. Okt 2003 23:25

Re: Ändern des Printerstatus
 
Lesen bildet:

Zitat:

Zitat von PSDK
If the Command parameter is PRINTER_CONTROL_SET_STATUS, pPrinter must contain a DWORD value that specifies the new printer status to set. For a list of the possible status values, see the Status member of the PRINTER_INFO_2 structure. Note that PRINTER_STATUS_PAUSED and PRINTER_STATUS_PENDING_DELETION are not valid status values to set.
If Level is 0, but the Command parameter is not PRINTER_CONTROL_SET_STATUS, pPrinter must be NULL.



Alle Zeitangaben in WEZ +1. Es ist jetzt 14:33 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz