E
EdwinYeah
Unregistered / Unconfirmed
GUEST, unregistred user!
下面这段程序,先得到一个窗口的句柄,再得到进程ID,再得到进程句柄,再终止进程,
但13行返回的为0,为什么?
98&2000都一样.
1procedure TForm1.Button1Click(Sender: TObject);
2var
3 ;aHwnd: HWND;
4 ;aProcID: DWORD;
5 ;aProcHandle: DWORD;
6begin
7 ;aHwnd := FindWindow(nil, 'WindowToBeClosed');
8 ;if aHwnd = 0 then
9 ; ;Exit;
10 ;aProcID := GetWindowThreadProcessId(aHwnd);
11 ;if aProcID = 0 then
12 ; ;Exit;
13 ;aProcHandle := OpenProcess(PROCESS_TERMINATE, False, aProcID);
14 ;if aProcHandle = 0 then
15 ; ;Exit;
16 ;TerminateProcess(aProcHandle, 0);
17end;
但13行返回的为0,为什么?
98&2000都一样.
1procedure TForm1.Button1Click(Sender: TObject);
2var
3 ;aHwnd: HWND;
4 ;aProcID: DWORD;
5 ;aProcHandle: DWORD;
6begin
7 ;aHwnd := FindWindow(nil, 'WindowToBeClosed');
8 ;if aHwnd = 0 then
9 ; ;Exit;
10 ;aProcID := GetWindowThreadProcessId(aHwnd);
11 ;if aProcID = 0 then
12 ; ;Exit;
13 ;aProcHandle := OpenProcess(PROCESS_TERMINATE, False, aProcID);
14 ;if aProcHandle = 0 then
15 ; ;Exit;
16 ;TerminateProcess(aProcHandle, 0);
17end;