我想通过单击一个按钮实现结束一个应用程序的功能
就是我现在用记事本打开了几个*.txt文件,当我单击结束 notepad.exe 程序的按钮时,会把他们都关掉

解决方案 »

  1.   

    Public Declare Function TerminateProcess Lib "kernel32" Alias "TerminateProcess" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
      

  2.   

    只要将进程中的所有NOTEPAD.EXE关掉就行了
      

  3.   

    Public Declare Function OpenProcess Lib "kernel32" Alias "OpenProcess" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
      

  4.   

    怎样获得 hProcess 
      

  5.   

    用GetWindowThreadProcessId得到进程ID  
    用OpenProcess打开进程,得到进程句柄  
     
    GetWindowThreadProcessId    
     
    VB声明    
    Declare  Function  GetWindowThreadProcessId  Lib  "user32"  Alias  "GetWindowThreadProcessId"  (ByVal  hwnd  As  Long,  lpdwProcessId  As  Long)  As  Long
      

  6.   

    Declare  Function  GetWindowThreadProcessId  Lib  "user32"  Alias  "GetWindowThreadProcessId"  (ByVal  hwnd  As  Long,  lpdwProcessId  As  Long)  As  Long
      

  7.   

    GetWindowThreadProcessId  获得的只进程ID的,不能直接用于TerminateProcess的,这个要遍历一下进程,其它方法我就不知道了