我是从asm来的,不会写delphi代码,给你一点建议,用enumwindows函数遍历非弹出式窗口,再编写回调函数关闭之.

解决方案 »

  1.   

    既然 能 得到句柄.发wm_destroy,或wm_quit给它试试.
    sendmessage如果不行,用postmessage.
      

  2.   

    我遇到过,好像用 WM_SYSCOMMAND 就可以了。
    SendMessage(ExeHandle, WM_SYSCOMMAND, SC_CLOSE, 0);
      

  3.   

    procedure CloseApp(appName: Pchar);
    var
      HWnd: HWnd;
      begin
       //Find the exist app window
       HWnd := FindWindow(nil, appName);
       if HWnd <> 0 then  // close the exist app
         SendMessage(HWnd, WM_CLOSE, 0, 0);
    end;
      

  4.   

    谢谢各位大侠的鼎力相助,经过试验,一下两条语句能实现在win2000上关闭资源管理器:SendMessage(ExeHandle, WM_SYSCOMMAND, SC_CLOSE, 0);
            postmessage(ExeHandle,WM_CLOSE,0,0);
    再次感谢各位的帮忙。
      

  5.   

    //==============================================================================
    //强制终止某应用程序运行********************************************************
    //==============================================================================
    procedure AppForceExit(const AppName: string);
    var lppe: TProcessEntry32;
        ssHandle: THandle;
        Wnd: HWND;
        AppFound: Boolean;
    begin
      ssHandle := CreateToolHelp32SnapShot(TH32CS_SNAPALL, 0);
      AppFound := Process32First(sshandle, lppe);
      while AppFound do
      begin
        //其中lppe.szExefile就是程序名**********************************************
        if UpperCase(ExtractFileName(lppe.szExeFile))=UpperCase(AppName) then
        begin
          Wnd := OpenProcess(PROCESS_ALL_ACCESS, true, lppe.th32ProcessID);
          TerminateProcess(Wnd, 0);
        end;
        AppFound := Process32Next(ssHandle, lppe);
      end;
    end;//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    procedure TForm_Main.Button18Click(Sender: TObject);
    begin
      case (Sender as TButton).Tag of
        0: ShellExecute(Handle, 'Open', PChar('ping.exe'), PChar('192.168.1.11 -t'), nil, SW_SHOWNORMAL);
        1: AppForceExit('ping.exe');
      end;
      (Sender as TButton).Tag := (Sender as TButton).Tag xor 1;
    end;
      

  6.   

    将SENDMESSAGE改为POSTMESSAGE就可以了