BSOne.SFC/eCrmHE/EXE_eCrmHomeEdition/DDummyMain.pas

123 lines
3.2 KiB
Plaintext

unit DDummyMain;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;
type
TDlgDummyMain = class(TForm)
tInit: TTimer;
tMtx: TTimer;
procedure tInitTimer(Sender: TObject);
procedure tMtxTimer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
Constructor Create(aOwner: TComponent); override;
procedure process_WM_ENDSESSION(var msg: TMessage); Message WM_ENDSESSION;
procedure process_WM_POWERBROADCAST(var msg: TMessage); Message WM_POWERBROADCAST;
end;
var
DlgDummyMain: TDlgDummyMain;
implementation
uses
Tocsg.Delete, ProcessParam, Tocsg.Win32, ProcessUninstall, Tocsg.Notification,
Tocsg.Trace, Tocsg.Path, GlobalDefine, Define, Tocsg.Registry, superobject;
resourcestring
RS_Deleted = '삭제되었습니다.';
{$R *.dfm}
Constructor TDlgDummyMain.Create(aOwner: TComponent);
begin
Inherited Create(aOwner);
if gParam.RunMode <> 0 then
tInit.Enabled := true;
end;
procedure TDlgDummyMain.tInitTimer(Sender: TObject);
begin
tInit.Enabled := false;
if gParam.RunMode = MODE_DELETE then
begin
UninstallCrmHE(GetCurrentProcessId);
if gParam.SelfDel then
begin
ShowNotification(APP_TITLE, RS_Deleted);
DeleteFileSelf;
end;
exit;
end;
if gParam.AliveMutex <> '' then
tMtx.Enabled := true;
end;
procedure TDlgDummyMain.tMtxTimer(Sender: TObject);
begin
if gParam.AliveMutex = '' then
begin
tMtx.Enabled := false;
exit;
end;
if not MutexExists(gParam.AliveMutex) then
begin
// tMtx.Enabled := false;
if gParam.SelfDel then
begin
DeleteFileSelf;
Sleep(10000);
end else
Close;
end;
end;
procedure TDlgDummyMain.process_WM_ENDSESSION(var msg: TMessage);
begin
// TDlgeCrmHeMain 여기에도 있음
// SetRegValueString(HKEY_LOCAL_MACHINE, REG_HE, 'EDT', IntToStr(DelphiToJavaDateTime(Now)), true);
WriteLnFileEndUTF8(GetRunExePathDir + BYE_ENDSESSION, 'bye');
// TerminateProcess(GetCurrentProcess, 100);
end;
procedure TDlgDummyMain.process_WM_POWERBROADCAST(var msg: TMessage);
begin
try
case msg.WParam of
PBT_APMSUSPEND :
begin
//설명: 시스템이 절전 모드로 전환되기 직전.
//처리: 애플리케이션은 작업을 저장하거나 필요한 정리 작업을 수행.
TTgTrace.T('process_WM_POWERBROADCAST() .. PBT_APMSUSPEND', 9);
end;
PBT_APMRESUMESUSPEND :
begin
//설명: 시스템이 절전 모드에서 복원된 후.
//처리: 애플리케이션은 중단된 작업을 다시 시작.
TTgTrace.T('process_WM_POWERBROADCAST() .. PBT_APMRESUMESUSPEND', 9);
end;
PBT_APMRESUMECRITICAL :
begin
//설명: 시스템이 치명적인 상황에서 복원됨. (예: 배터리 부족 등)
//처리: 애플리케이션은 복구 작업을 수행.
TTgTrace.T('process_WM_POWERBROADCAST() .. PBT_APMRESUMECRITICAL', 9);
end;
end;
except
// on E: Exception do
// ETgException.TraceException(Self, E, 'Fail .. process_WM_POWERBROADCAST()');
end;
end;
end.