BSOne.SFC/eCrmHE/EXE_eCrmHomeEdition/Process/ProcessParam.pas

131 lines
2.6 KiB
Plaintext

{*******************************************************}
{ }
{ ProcessParam }
{ }
{ Copyright (C) 2022 kku }
{ }
{*******************************************************}
unit ProcessParam;
interface
uses
Tocsg.Param, System.SysUtils, Winapi.Windows;
const
MODE_DELETE = 10;
MODE_DUMMY = 11;
MODE_SHOW_REMOVE_NOTI = 12;
type
TProcessParam = class(TTgParam)
private
nRunMode_: Integer;
bSelfDel_: Boolean;
sInstDir_,
sAliveMutex_: String;
public
Constructor Create;
Destructor Destroy; override;
function ProcessParam: Boolean;
property RunMode: Integer read nRunMode_;
property SelfDel: Boolean read bSelfDel_;
property InstDir: String read sInstDir_;
property AliveMutex: String read sAliveMutex_;
end;
var
gParam: TProcessParam = nil;
implementation
uses
superobject, ProcessUninstall, Tocsg.Notification, Tocsg.Delete,
Tocsg.Path, Tocsg.Process, GlobalDefine, DefineHelper, Define;
resourcestring
RS_Deleted = '삭제되었습니다.';
{ TProcessParam }
Constructor TProcessParam.Create;
begin
Inherited Create;
ASSERT(gParam = nil);
gParam := Self;
bSelfDel_ := false;
nRunMode_ := 0;
sInstDir_ := '';
sAliveMutex_ := '';
end;
Destructor TProcessParam.Destroy;
begin
gParam := nil;
Inherited;
end;
function TProcessParam.ProcessParam: Boolean;
procedure ShowNoti(sTitle, sText: String);
var
sExe: String;
ProcInfo: TProcessInformation;
begin
sExe := GetRunExePath;
if FileExists(sExe) then
begin
ProcInfo := ExecuteAppAsUser('explorer.exe', sExe, '/rn', SW_HIDE);
if ProcInfo.dwProcessId = 0 then
ShowNotification(sTitle, sText)
else Sleep(500);
end;
end;
var
sIPath: String;
O: ISuperObject;
begin
if ParamCount > 0 then
begin
Result := false;
if ExistsParam('/rn') then
begin
ShowNotification(APP_TITLE, RS_Deleted);
exit;
end;
sIPath := GetParamValue('-i');
if not LoadJsonObjFromFile(O, sIPath) then
exit;
DeleteFile(PChar(sIPath));
nRunMode_ := O.I['M'];
bSelfDel_ := O.B['SD'];
sInstDir_ := O.S['ID'];
sAliveMutex_ := O.S['AM'];
end;
case nRunMode_ of
0 : ;
MODE_DELETE :
begin
UninstallCrmHE(GetCurrentProcessId);
if gParam.SelfDel then
begin
// ShowNoti(APP_TITLE, '삭제되었습니다.');
DeleteFileSelf;
end;
exit;
end;
end;
Result := true;
end;
end.