EnumWindows
The EnumWindows function enumerates all top-level windows on the screen by passing the handle to each window, in turn, to an application-defined callback function. EnumWindows continues until the last top-level window is enumerated or the callback function returns FALSE. BOOL EnumWindows(
  WNDENUMPROC lpEnumFunc,  // pointer to callback function
  LPARAM lParam            // application-defined value
);
 
Parameters
lpEnumFunc 
Pointer to an application-defined callback function. For more information, see EnumWindowsProc. 
lParam 
Specifies an application-defined value to be passed to the callback function. 
Return Values
If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, callGetLastError.Res
The EnumWindows function does not enumerate child windows. This function is more reliable than calling the GetWindow function in a loop. An application that calls GetWindow to perform this task risks being caught in an infinite loop or referencing a handle to a window that has been destroyed. 

解决方案 »

  1.   

    TerminateProcess
    The TerminateProcess function terminates the specified process and all of its threads. BOOL TerminateProcess(
      HANDLE hProcess, // handle to the process
      UINT uExitCode   // exit code for the process
    );
     
    Parameters
    hProcess 
    Handle to the process to terminate. 
    Windows NT: The handle must have PROCESS_TERMINATE access. uExitCode 
    Specifies the exit code for the process and for all threads terminated as a result of this call. Use the GetExitCodeProcess function to retrieve the process's exit value. Use the GetExitCodeThread function to retrieve a thread's exit value. 
    Return Values
    If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError. Res
    The TerminateProcess function is used to unconditionally cause a process to exit. Use it only in extreme circumstances. The state of global data maintained by dynamic-link libraries (DLLs) may be compromised if TerminateProcess is used rather than ExitProcess. TerminateProcess causes all threads within a process to terminate, and causes a process to exit, but DLLs attached to the process are not notified that the process is terminating. Terminating a process causes the following: All of the object handles opened by the process are closed. 
    All of the threads in the process terminate their execution. 
    The state of the process object becomes signaled, satisfying any threads that had been waiting for the process to terminate. 
    The states of all threads of the process become signaled, satisfying any threads that had been waiting for the threads to terminate. 
    The termination status of the process changes from STILL_ACTIVE to the exit value of the process. 
    Terminating a process does not cause child processes to be terminated. Terminating a process does not necessarily remove the process object from the system. A process object is deleted when the last handle to the process is closed. Windows CE: Windows CE does not support exit codes for processes, so the uExitCode parameter is ignored.QuickInfo
      Windows NT: Requires version 3.1 or later.
      Windows: Requires Windows 95 or later.
      Windows CE: Requires version 1.0 or later.
      Header: Declared in winbase.h.
      Import Library: Use kernel32.lib.
      

  2.   

    WM_CLOSE
    The WM_CLOSE message is sent as a signal that a window or an application should terminate. WM_CLOSE 
     
    Parameters
    This message has no parameters. Return Values
    If an application processes this message, it should return zero. Default Action
    The DefWindowProc function calls the DestroyWindow function to destroy the window. Res
    An application can prompt the user for confirmation, prior to destroying a window, by processing the WM_CLOSE message and calling the DestroyWindow function only if the user confirms the choice. 
      

  3.   

    use timer,
    每隔20分钟就遍历一遍所有进程,然后发现了你特定的进程时(比如金山毒霸),就关闭它就行了
      

  4.   

    查找窗口的名称,用copy,得到字符,比如发现毒霸,就close
      

  5.   

    选将经常使用的杀毒软件名字放在一个数据库里,然后每二十分钟遍历一遍所有进程
    发现了相近的就SendMessage(...)
      

  6.   

    补充一点:
    有些Win2KServer程序是不能用TerminateProcess或发送WM_CLOSE消息可以关闭的。
    需要用TLHelp32的函数去找到它的文件名,然后 file /uninstall才能关闭。 
      

  7.   

    枚举窗口并得到它的标题,然后做判断
    用到的API有:EnumWindows,EnumWindowProc(回调函数),GetWindowTitle
    具体用法参见sdk帮助
      

  8.   

    在枚举的过程中,记录窗口的句柄,在PostMessage(..,WM_CLOSE,..)就行了