Added new function allowing automatic system shutdown after rendering completion.
This commit is contained in:
parent
d8bd40db89
commit
ed5d08220c
@ -1,10 +1,10 @@
|
||||
object RenderForm: TRenderForm
|
||||
Left = 280
|
||||
Top = 279
|
||||
Left = 286
|
||||
Top = 251
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
BorderStyle = bsSingle
|
||||
Caption = 'RenderForm'
|
||||
ClientHeight = 400
|
||||
ClientHeight = 405
|
||||
ClientWidth = 424
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
@ -297,9 +297,9 @@ object RenderForm: TRenderForm
|
||||
object lblPhysical: TLabel
|
||||
Left = 202
|
||||
Top = 20
|
||||
Width = 121
|
||||
Width = 126
|
||||
Height = 13
|
||||
Caption = 'Available phycial memory:'
|
||||
Caption = 'Available physical memory:'
|
||||
end
|
||||
object Label9: TLabel
|
||||
Left = 8
|
||||
@ -346,7 +346,7 @@ object RenderForm: TRenderForm
|
||||
end
|
||||
object chkSave: TCheckBox
|
||||
Left = 8
|
||||
Top = 354
|
||||
Top = 346
|
||||
Width = 113
|
||||
Height = 17
|
||||
Caption = 'Save parameters'
|
||||
@ -408,7 +408,7 @@ object RenderForm: TRenderForm
|
||||
end
|
||||
object StatusBar: TStatusBar
|
||||
Left = 0
|
||||
Top = 381
|
||||
Top = 386
|
||||
Width = 424
|
||||
Height = 19
|
||||
Panels = <
|
||||
@ -422,6 +422,14 @@ object RenderForm: TRenderForm
|
||||
Width = 50
|
||||
end>
|
||||
end
|
||||
object chkShutdown: TCheckBox
|
||||
Left = 8
|
||||
Top = 368
|
||||
Width = 137
|
||||
Height = 17
|
||||
Caption = 'Shutdown on complete'
|
||||
TabOrder = 11
|
||||
end
|
||||
object SaveDialog: TSaveDialog
|
||||
Left = 368
|
||||
Top = 256
|
||||
|
@ -66,6 +66,7 @@ type
|
||||
cbWidth: TComboBox;
|
||||
cbHeight: TComboBox;
|
||||
StatusBar: TStatusBar;
|
||||
chkShutdown: TCheckBox;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure btnRenderClick(Sender: TObject);
|
||||
@ -96,6 +97,7 @@ type
|
||||
procedure HandleThreadTermination(var Message: TMessage);
|
||||
message WM_THREAD_TERMINATE;
|
||||
procedure ListPresets;
|
||||
function WindowsExit(RebootParam: Longword = EWX_POWEROFF or EWX_FORCE): Boolean;
|
||||
public
|
||||
Renderer: TRenderThread;
|
||||
PhysicalMemory, ApproxMemory: int64;
|
||||
@ -170,6 +172,8 @@ begin
|
||||
Renderer.Free;
|
||||
Renderer := nil;
|
||||
ResetControls;
|
||||
if chkShutdown.Checked then
|
||||
WindowsExit;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
@ -667,5 +671,44 @@ begin
|
||||
Ratio := ImageWidth / ImageHeight;
|
||||
end;
|
||||
|
||||
function TRenderForm.WindowsExit(RebootParam: Longword = EWX_POWEROFF or EWX_FORCE): Boolean;
|
||||
var
|
||||
TTokenHd: THandle;
|
||||
TTokenPvg: TTokenPrivileges;
|
||||
cbtpPrevious: DWORD;
|
||||
rTTokenPvg: TTokenPrivileges;
|
||||
pcbtpPreviousRequired: DWORD;
|
||||
tpResult: Boolean;
|
||||
const
|
||||
SE_SHUTDOWN_NAME = 'SeShutdownPrivilege';
|
||||
begin
|
||||
if ((GetWinVersion = wvWinNT) or
|
||||
(GetWinVersion = wvWin2000) or
|
||||
(GetWinVersion = wvWinXP)) then
|
||||
begin
|
||||
tpResult := OpenProcessToken(GetCurrentProcess(),
|
||||
TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,
|
||||
TTokenHd);
|
||||
if tpResult then
|
||||
begin
|
||||
tpResult := LookupPrivilegeValue(nil,
|
||||
SE_SHUTDOWN_NAME,
|
||||
TTokenPvg.Privileges[0].Luid);
|
||||
TTokenPvg.PrivilegeCount := 1;
|
||||
TTokenPvg.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
|
||||
cbtpPrevious := SizeOf(rTTokenPvg);
|
||||
pcbtpPreviousRequired := 0;
|
||||
if tpResult then
|
||||
Windows.AdjustTokenPrivileges(TTokenHd,
|
||||
False,
|
||||
TTokenPvg,
|
||||
cbtpPrevious,
|
||||
rTTokenPvg,
|
||||
pcbtpPreviousRequired);
|
||||
end;
|
||||
end;
|
||||
Result := ExitWindowsEx(RebootParam, 0);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
object MainForm: TMainForm
|
||||
Left = 316
|
||||
Top = 424
|
||||
Left = 411
|
||||
Top = 128
|
||||
Width = 574
|
||||
Height = 575
|
||||
Caption = 'Apophysis'
|
||||
@ -27,7 +27,7 @@ object MainForm: TMainForm
|
||||
Left = 160
|
||||
Top = 28
|
||||
Width = 4
|
||||
Height = 494
|
||||
Height = 482
|
||||
end
|
||||
object ToolBar: TToolBar
|
||||
Left = 0
|
||||
@ -251,7 +251,7 @@ object MainForm: TMainForm
|
||||
Left = 0
|
||||
Top = 28
|
||||
Width = 160
|
||||
Height = 494
|
||||
Height = 482
|
||||
Align = alLeft
|
||||
Columns = <
|
||||
item
|
||||
@ -270,7 +270,7 @@ object MainForm: TMainForm
|
||||
Left = 164
|
||||
Top = 28
|
||||
Width = 402
|
||||
Height = 494
|
||||
Height = 482
|
||||
Align = alClient
|
||||
BevelInner = bvLowered
|
||||
BevelOuter = bvNone
|
||||
@ -281,7 +281,7 @@ object MainForm: TMainForm
|
||||
Left = 1
|
||||
Top = 1
|
||||
Width = 400
|
||||
Height = 472
|
||||
Height = 480
|
||||
Align = alClient
|
||||
AutoSize = True
|
||||
PopupMenu = DisplayPopup
|
||||
@ -293,7 +293,7 @@ object MainForm: TMainForm
|
||||
end
|
||||
object StatusBar: TStatusBar
|
||||
Left = 0
|
||||
Top = 522
|
||||
Top = 510
|
||||
Width = 566
|
||||
Height = 19
|
||||
Panels = <
|
||||
@ -2919,8 +2919,9 @@ object MainForm: TMainForm
|
||||
end
|
||||
object HTTP: TIdHTTP
|
||||
OnStatus = HTTPStatus
|
||||
MaxLineAction = maException
|
||||
ReadTimeout = 0
|
||||
AuthRetries = 0
|
||||
AuthProxyRetries = 0
|
||||
AllowCookies = True
|
||||
ProxyParams.BasicAuthentication = False
|
||||
ProxyParams.ProxyPort = 0
|
||||
|
@ -41,6 +41,8 @@ const
|
||||
type
|
||||
TMouseMoveState = (msUsual, msZoomWindow, msZoomWindowMove, msDrag, msDragMove, msRotate, msRotateMove);
|
||||
|
||||
type
|
||||
TWin32Version = (wvUnknown, wvWin95, wvWin98, wvWinNT, wvWin2000, wvWinXP);
|
||||
|
||||
type
|
||||
pRGBTripleArray = ^TRGBTripleArray;
|
||||
@ -344,6 +346,7 @@ procedure ListFlames(FileName: string; sel: integer);
|
||||
procedure ListIFS(FileName: string; sel: integer);
|
||||
procedure AdjustScale(var cp1: TControlPoint; width, height: integer);
|
||||
procedure NormalizeVariations(var cp1: TControlPoint);
|
||||
function GetWinVersion: TWin32Version;
|
||||
|
||||
var
|
||||
MainForm: TMainForm;
|
||||
@ -497,6 +500,25 @@ begin
|
||||
Variations[i] := boolean(v shr i and 1);
|
||||
end;
|
||||
|
||||
function GetWinVersion: TWin32Version;
|
||||
{ Returns current version of a host Win32 platform }
|
||||
begin
|
||||
Result := wvUnknown;
|
||||
if Win32Platform = VER_PLATFORM_WIN32_WINDOWS then
|
||||
if (Win32MajorVersion > 4) or
|
||||
((Win32MajorVersion = 4) and
|
||||
(Win32MinorVersion > 0)) then
|
||||
Result := wvWin98
|
||||
else
|
||||
Result := wvWin95
|
||||
else
|
||||
if Win32MajorVersion <= 4 then
|
||||
Result := wvWinNT
|
||||
else
|
||||
if Win32MajorVersion = 5 then
|
||||
Result := wvWin2000
|
||||
end;
|
||||
|
||||
{ ************************************* Help ********************************* }
|
||||
|
||||
procedure ShowHelp(Pt: TPoint; ContextId: Integer);
|
||||
|
Loading…
Reference in New Issue
Block a user