请高手帮忙!最好有源代码!

解决方案 »

  1.   

    简单的方法是用FindWindow,再发送WM_CLOSE消息。但这对某些程序无效。也可以列举系统的进程,根据进程找到文件名,符合则杀掉。
      

  2.   

    SendMessage(FindWindow(nil,Pchar('YourApplicationTitle'), WM_CLose,0,0));
      

  3.   

    //需要uses TLhelp32;
    KillTask(ExeFileName: string): integer;
    const
    PROCESS_TERMINATE=$0001;
    var
    ContinueLoop: BOOL;
    FSnapshotHandle: THandle;
    FProcessEntry32: TProcessEntry32;
    beginresult := 0;
    FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
    ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32);
    while integer(ContinueLoop) <> 0 do
    begin
    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
    UpperCase(ExeFileName))
    or (UpperCase(FProcessEntry32.szExeFile) =
    UpperCase(ExeFileName))) then
    Result := Integer(TerminateProcess(OpenProcess(
    PROCESS_TERMINATE,
    BOOL(0),
    FProcessEntry32.th32ProcessID),0));ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32);
    end;
    CloseHandle(FSnapshotHandle);
    end;
    //使用
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    KillTask('notepad.exe');
    end;
    procedure TForm1.Button4Click(Sender: TObject);
    begin
    KillTask('notepad.exe');
    end;
      

  4.   

    哦,写错了
    SendMessage(FindWindow(nil,Pchar('YourApplicationTitle')), WM_CLose,0,0));
      

  5.   

    楼主,借你的题目再发挥一下,
     cosmart(CoolSmart) ,如果我找到了那个正在运行的程序,但是它的界面是隐藏的,如何把该程序的界面显示出来呢?
    就像windows的任务管理器那样。