111 lines
2.7 KiB
Plaintext
111 lines
2.7 KiB
Plaintext
{*******************************************************}
|
|
{ }
|
|
{ ProcessUninstall }
|
|
{ }
|
|
{ Copyright (C) 2022 kku }
|
|
{ }
|
|
{*******************************************************}
|
|
|
|
unit ProcessUninstall;
|
|
|
|
interface
|
|
|
|
uses
|
|
System.SysUtils, Winapi.Windows, System.Classes;
|
|
|
|
function UninstallCrmHE(dwExitIgrPid: DWORD = 0; bIgrDelCfg: Boolean = false): Boolean;
|
|
|
|
implementation
|
|
|
|
uses
|
|
Tocsg.Path, Tocsg.Process, Tocsg.Service, Tocsg.Files, GlobalDefine,
|
|
Tocsg.Win32, Tocsg.Safe, ManagerModel;
|
|
|
|
function UninstallCrmHE(dwExitIgrPid: DWORD = 0; bIgrDelCfg: Boolean = false): Boolean;
|
|
var
|
|
sSysDir,
|
|
sInstDir: String;
|
|
nTO: Integer;
|
|
KillMtx: TTgMutex;
|
|
IgrList: TStringList;
|
|
begin
|
|
Result := false;
|
|
|
|
Guard(KillMtx, TTgMutex.Create(MUTEX_KILL));
|
|
nTO := 0;
|
|
// 먼저... 알아서 죽도록 기다림
|
|
while MutexExists(MUTEX_AGENT) or MutexExists(MUTEX_SERVICE) do
|
|
begin
|
|
Inc(nTO);
|
|
Sleep(500);
|
|
|
|
if nTO >= 20 then
|
|
break;
|
|
end;
|
|
|
|
sInstDir := GetProgramFilesDir + DIR_HE;
|
|
if not DirectoryExists(sInstDir) then
|
|
begin
|
|
Result := true;
|
|
exit;
|
|
end;
|
|
|
|
TerminateProcessByName(EXE_SV);
|
|
TerminateProcessByName(EXE_SL);
|
|
TerminateProcessByName(EXE_HE, dwExitIgrPid);
|
|
TerminateProcessByName('javaw.exe');
|
|
TerminateProcessByName(EXE_MG);
|
|
TerminateProcessByName(EXE_RT);
|
|
TerminateProcessByName(EXE_GC);
|
|
TerminateProcessByName(EXE_IC);
|
|
|
|
sSysDir := GetSystemDir;
|
|
SetVisibleServce(NAME_SERVICE, true);
|
|
Sleep(1000);
|
|
if ServiceExists(NAME_SERVICE) then
|
|
begin
|
|
if FileExists(sSysDir + DLL_SV) then
|
|
UninstallServiceDll(sSysDir + DLL_SV)
|
|
else
|
|
UninstallService(NAME_SERVICE);
|
|
end;
|
|
if ServiceExists(NAME_SERVICE_OLD) then
|
|
UninstallService(NAME_SERVICE_OLD);
|
|
Sleep(500);
|
|
|
|
DeleteFile(PChar(sSysDir + EXE_SV));
|
|
DeleteFile(PChar(sSysDir + DLL_SV));
|
|
DeleteFile(PChar(sSysDir + EXE_SL));
|
|
DeleteFile(PChar(sSysDir + BAT_HE));
|
|
|
|
IgrList := nil;
|
|
if bIgrDelCfg then
|
|
begin
|
|
IgrList := TStringList.Create;
|
|
IgrList.Add(DAT_PREF);
|
|
IgrList.Add(DAT_AGENT);
|
|
IgrList.Add(PROP_USERINFO);
|
|
IgrList.Add('bin');
|
|
end;
|
|
|
|
try
|
|
nTO := 0;
|
|
while (nTO < 20) and not Result do
|
|
begin
|
|
DeleteDir(sInstDir, true, true, IgrList);
|
|
Sleep(500);
|
|
Inc(nTO);
|
|
Result := not DirectoryExists(sInstDir);
|
|
|
|
// 음.. 패치는 전체 다 삭제 안되는게 정상이니까 일단 이렇게 처리...
|
|
if (IgrList <> nil) and (nTO > 2) then
|
|
break;
|
|
end;
|
|
finally
|
|
if IgrList <> nil then
|
|
FreeAndNil(IgrList);
|
|
end;
|
|
end;
|
|
|
|
end.
|