![]() |
Re: Process Priorität setzen - als Variable...
Irgendwie nicht...
Könntest du die Source ggf. umschreiben, damit ich weis was ich falsch gemacht hatte?
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin ComboBox1.Style:=csDropDownList; ComboBox1.Items.AddObject('Idle Priorität',TObject(IDLE_PRIORITY_CLASS)); ComboBox1.Items.AddObject('Normale Priorität',TObject(NORMAL_PRIORITY_CLASS)); ComboBox1.Items.AddObject('High Priorität',TObject(HIGH_PRIORITY_CLASS)); end;
Delphi-Quellcode:
Es bleibt immer NORMAL...
ProcID := 0;
RunProcess('Test.bat', SW_SHOW, True, @ProcID, Cardinal(ComboBox1.Items.Objects[ComboBox1.ItemIndex]) ); end; procedure TForm1.ComboBox1Change(Sender: TObject); begin if form1.ComboBox1.ItemIndex=0 then form1.Edit1.Text:='IDLE'; if form1.ComboBox1.ItemIndex=1 then form1.Edit1.Text:='NORMAL'; if form1.ComboBox1.ItemIndex=2 then form1.Edit1.Text:='HIGH'; end; |
Re: Process Priorität setzen - als Variable...
Delphi-Quellcode:
if not CreateProcess(nil,
function RunProcess(FileName: string; ShowCmd: DWORD; wait: Boolean; ProcID: PDWORD): Longword;
var StartupInfo: TStartupInfo; ProcessInfo: TProcessInformation; begin FillChar(StartupInfo, SizeOf(StartupInfo), #0); StartupInfo.cb := SizeOf(StartupInfo); StartupInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK; StartupInfo.wShowWindow := ShowCmd; if not CreateProcess(nil, @Filename[1], nil, nil, False, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo) then Result := WAIT_FAILED else begin if wait = FALSE then begin if ProcID <> nil then ProcID^ := ProcessInfo.dwProcessId; exit; end; WaitForSingleObject(ProcessInfo.hProcess, INFINITE); GetExitCodeProcess(ProcessInfo.hProcess, Result); end; if ProcessInfo.hProcess <> 0 then CloseHandle(ProcessInfo.hProcess); if ProcessInfo.hThread <> 0 then CloseHandle(ProcessInfo.hThread); end; @Filename[1], nil, nil, False, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo) then Ich muss die ROTE Zeile irgendwie als Variable haben. Nur wie? Wenn ich statt NORMAL_PRIORITY_CLASS IDLE_PRIORITY_CLASS schreibe ist die Anwendung in der IDLE_PRIORITY_CLASS. Nur will ich das per Combobox verändern können. |
Re: Process Priorität setzen - als Variable...
Moin DRPEnc,
also ich kann da nichts Falsches sehen und (allgemein unbeliebte Ergänzung ;-) ): Bei mir funktioniert's. Was geht denn nicht? BTW: Ich hab' noch mal die FormCreate und ComboBox1Change etwas "überarbeitet"
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin ComboBox1.Style:=csDropDownList; ComboBox1.Items.AddObject('Idle Priorität',TObject(IDLE_PRIORITY_CLASS)); ComboBox1.Items.AddObject('Normale Priorität',TObject(NORMAL_PRIORITY_CLASS)); ComboBox1.Items.AddObject('High Priorität',TObject(HIGH_PRIORITY_CLASS)); // Normal als Default auswählen ComboBox1.ItemIndex := 1; // die Ereignisroutine aufrufen, passiert bei Zuweisung an ItemIndex nicht ComboBox1Change(nil); end; procedure TForm1.ComboBox1Change(Sender: TObject); // Mit einer Liste wird's etwas übersichtlicher const _asPriorities : array [0..2] of String = ('IDLE','NORMAL','HIGH'); begin Edit1.Text := _asPriorities[ComboBox1.ItemIndex]; // Nur um zu zeigen, dass auch jeweils eine andere Konstante ausgewählt wird Edit2.Text := IntToStr(Integer(ComboBox1.Items.Objects[ComboBox1.ItemIndex])); end; |
Re: Process Priorität setzen - als Variable...
Moin DRPEnc,
stimmt, an der Stelle kann man es auch festlegen. Da hab' ich gepennt :?
Code:
Aber der andere Weg geht auch ;-)
if not CreateProcess(nil,
@Filename[1], nil, nil, False, CREATE_NEW_CONSOLE or [color=red]AdwProcessPriority, <==== Statt der Konstanten, einfach den zusätzlichen Parameter angeben[/color] nil, nil, StartupInfo, ProcessInfo) then |
Re: Process Priorität setzen - als Variable...
Irgendwie bekomm ichs nicht hin... Kannst Du mir Deine Source posten?
|
Re: Process Priorität setzen - als Variable...
Liste der Anhänge anzeigen (Anzahl: 1)
Moin DRPEnc,
ich hab's mal als Datei angehängt. Du brauchst noch einen Button zwei Edit eine ComboBox einen OpenDialog (damit man die zu startende Datei auswählen kann) |
Re: Process Priorität setzen - als Variable...
Liste der Anhänge anzeigen (Anzahl: 1)
Ich habs mal zusammengebaut, aber läuft nicht...
Wenn ich nach der Zeile
Delphi-Quellcode:
IDLE_PRITORITY_CLASS
nil,
nil, False, CREATE_NEW_CONSOLE or schreibe läuft das Programm im IDLE-Mode. Steht aber AdwProcessPriority, passiert nichts. Schaus Dir selber an. Anbei die Compilierung mit Source. Was mir aufgefallen ist: Edit2 zeigt tuschur NULL... |
Re: Process Priorität setzen - als Variable...
Nur wenn ich den konstanten Wert verändere funtzts. Irgendwie wird AdwProcessPriority nicht aktiviert.
Irgendwas wurde noch vergessen. Wird die Funktion vor der Combobox erzeugt? |
Re: Process Priorität setzen - als Variable...
Moin DRPEnc,
Zitat:
|
Re: Process Priorität setzen - als Variable...
Moin DRPEnc,
in Deinem Code von 00:03 fehlt übrigens bei RunProcess der Parameter mit der ProcessPriority. Wird der überhaupt übergeben? Wenn nicht wäre das evtl. eine Erklärung dafür, warum es nicht funktioniert. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:53 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