Ich habe das Ganze nochmal überdacht und den Aufruf der proceduren global geregelt. Dank eurer Hilfe sollte es hoffentlich so korrekt sein:
Delphi-Quellcode:
unit ShutDown;
interface
uses
Windows, Messages, SysUtils, Classes;
type
TShutDown =
class(TObject)
private
procedure GetPrivileges;
procedure Shutdown(PowerOff,Force :boolean);
procedure Ruhezustand(Force :boolean);
procedure Standby(Force :boolean);
procedure Logoff(Force : boolean);
procedure Restart(Force :boolean);
public
procedure beenden;
end;
implementation
uses Config,main_menue;
procedure TShutDown.GetPrivileges;
//Rechte um runterzufahren holen.
...
...
...
procedure TShutDown.beenden;
begin
case config_frm.ShutdownSelect.ItemIndex
of
0:
begin
Main_frm.Close;
end;
1:
begin
Main_frm.Close;
Shutdown(true,config_frm.ShutDown_force_select.Checked);
end;
2:
begin
Ruhezustand(config_frm.ShutDown_force_select.Checked);
end;
3:
begin
Standby(config_frm.ShutDown_force_select.Checked);
end;
4:
begin
Main_frm.Close;
Restart(config_frm.ShutDown_force_select.Checked);
end;
end;
end;
der Aufruf aus der anderen Form/
Unit dann:
Delphi-Quellcode:
procedure Tmediaplayer_frm.Image14Click(Sender: TObject);
var
SShutDown: TShutDown;
begin
SShutDown := TShutDown.Create;
try
SShutDown.beenden;
finally
FreeAndNil(SShutDown);
end;
end;