Pega:能否再透露一点NT4.0下的 Kill Process大法?(200分)

  • 主题发起人 主题发起人 jghuang
  • 开始时间 开始时间
J

jghuang

Unregistered / Unconfirmed
GUEST, unregistred user!
95,98下的 Process32First, Process32Next,在NT下不支持。
那么怎样获得当前运行中的进程的ProcessID &
Handle呢? 进程的Modue Name已知。
我曾用Spy++取得特定的ProcessID 并用OpenProcess()试图取得它的Handle,没报错,
但好象不行,总是一个值。
然后CloseHandle(),但毫无反应。:(
我也看过Pviewer 例子,但是稀里糊涂,还是再问Pega大虾吧。
先谢了。
 
Anybody, Anyvoice, Can you hear me?
Oh, Ido
n't want to waste my time and money.
 
用TERMINATRPROCESS函数.
BOOL TerminateProcess(
HANDLE hProcess, // handle to the process
UINT uExitCode // exit code for the process
);

你OPENPROCESS的用法请注意
HANDLE OpenProcess(
DWORD dwDesiredAccess, // access flag
BOOL bInheritHandle, // handle inheritance flag
DWORD dwProcessId // process identifier
);
 
My major issue is how can I get the ProcessID and Handle of the Process.
Do you have any suggestions?
 
GetWindowProcessID
 
DWORD GetWindowThreadProcessId(
HWND hWnd, // handle to window
LPDWORD lpdwProcessId // address of variable for process identifier
);
lpdwProcessId 就是PROCESSID.
 
cytown说的没错,我怎么把MFC抬出来了?
 
Thank you tqz, I get the function"GetWindowThreadProcessId" in the MSDN from the one you give.
And my program can work now.
 
Oh, cytown, thank you too. You've give me the right one.
And I have another question now.
How can I close my console window automatically after running it?
Not press any key and the way above.
Of course, I want another method.
 
yes,u cannot close it in oncreate/onshow/onactive event
instead, u need a ttimer, and after a sertified time past,then
close the win.
good luck
 
CJ: I use VC now. So...
All:
Thanks for your helping, and it's OK now.
And I needn't close the window for my console app, for the window is create by the system when I debug the program.
And if I run it outside the VC IDE, the window will be closed by system after the job is finished.
 
多人接受答案了。
 
后退
顶部