BSOne.SFC/Tocsg.Module/EjectDLL/DEjectDllMain.pas

102 lines
2.4 KiB
Plaintext

unit DEjectDllMain;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, ThdMsgAutoClose;
type
TDlgEjectDllMain = class(TForm)
Label1: TLabel;
edPid: TEdit;
btnEject: TButton;
mmDlls: TMemo;
btnAutoClose: TButton;
procedure btnEjectClick(Sender: TObject);
procedure btnAutoCloseClick(Sender: TObject);
private
{ Private declarations }
ThdMsgAutoClose_: TThdMsgAutoClose;
public
{ Public declarations }
Constructor Create(aOwner: TComponent); override;
Destructor Destroy; override;
end;
var
DlgEjectDllMain: TDlgEjectDllMain;
implementation
uses
Tocsg.Strings, Tocsg.Safe, Tocsg.Process, Tocsg.WndUtil;
{$R *.dfm}
Constructor TDlgEjectDllMain.Create(aOwner: TComponent);
begin
Inherited Create(aOwner);
ThdMsgAutoClose_ := nil;
end;
Destructor TDlgEjectDllMain.Destroy;
begin
if ThdMsgAutoClose_ <> nil then
FreeAndNil(ThdMsgAutoClose_);
Inherited;
end;
procedure TDlgEjectDllMain.btnAutoCloseClick(Sender: TObject);
begin
if ThdMsgAutoClose_= nil then
begin
ThdMsgAutoClose_ := TThdMsgAutoClose.Create;
ThdMsgAutoClose_.StartThread;
btnAutoClose.Caption := '닫기 OFF';
MessageBox(Handle, PChar('자동 닫기 시작'), PChar(Caption), MB_ICONINFORMATION or MB_OK);
end else begin
FreeAndNil(ThdMsgAutoClose_);
btnAutoClose.Caption := '닫기 ON';
MessageBox(Handle, PChar('자동 닫기 중지'), PChar(Caption), MB_ICONINFORMATION or MB_OK);
end;
Application.ProcessMessages;
end;
procedure TDlgEjectDllMain.btnEjectClick(Sender: TObject);
var
dwPid: DWORD;
sEjectDlls: String;
StrList: TStringList;
i, n: Integer;
begin
dwPid := StrToInt64Def(Trim(edPid.Text), 0);
if dwPid = 0 then
begin
MessageBox(Handle, PChar('PID를 입력해 주십시오.'), PChar(Caption), MB_ICONWARNING or MB_OK);
exit;
end;
sEjectDlls := Trim(mmDlls.Text);
if sEjectDlls = '' then
begin
MessageBox(Handle, PChar('DLL을 입력해 주십시오.'), PChar(Caption), MB_ICONWARNING or MB_OK);
exit;
end;
sEjectDlls := StringReplace(sEjectDlls, #13#10, '|', [rfReplaceAll]);
Guard(StrList, TStringList.Create);
SplitString(sEjectDlls, '|', StrList);
n := 0;
for i := 0 to StrList.Count - 1 do
begin
Inc(n, EjectModuleFromName(StrList[i], dwPid));
end;
MessageBox(Handle, PChar(Format('성공 : %d', [n])), PChar(Caption), MB_ICONINFORMATION or MB_OK);
end;
end.