各位大虾,小弟有两个问题需要请教,还望各位大虾不吝赐教,解决问题马上给分!
1、例如我安装了一个软件,现知道他的名称为top2000,怎样才能取得他的可执行程序的路径,可执行文件为:top2000.exe2、还是上面那个top2000.exe,在他运行后,请问怎样才能使用delphi程序关闭他?
1、例如我安装了一个软件,现知道他的名称为top2000,怎样才能取得他的可执行程序的路径,可执行文件为:top2000.exe2、还是上面那个top2000.exe,在他运行后,请问怎样才能使用delphi程序关闭他?
var
hWndClose: HWnd;
str: String;
begin
str := InputBox('提示','请输入应用程序名:','');
if str <> '' then
begin
hWndClose := FindWindow(nil, PChar(str));
if hWndClose <> 0 then
SendMessage(hWndClose,WM_CLOSE,0,0)
else
ShowMessage('没找到指定的应用程序,所以无法关闭!');
end;
end;
procedure TForm12.Button2Click(Sender: TObject);
var
wnd :HWND;
begin
wnd := FindWindow(nil,'未定标题 - 记事本');//应用程序的标题名
if wnd <>0 then
if isiconic(wnd) then
ShowWindow(wnd,sw_restore)
else
SetForegroundWindow(wnd)
else
showmessage('no such window');
end;