J
Jon Skeet [C# MVP]
I was just having a look at the code for Process.Kill, and it looks
somewhat wrong to me. In particular, it calls
OpenProcess (0, false, this.Handle)
but this.Handle is actually the result of calling OpenProcess in the
first place with the process ID.
Should the code not just call (after checking for exit etc)
TerminateProcess (Handle, 0);
? Why the two levels of OpenProcess? The last parameter of OpenProcess
is a DWORD, not a HANDLE, which also suggests there's something wrong.
On a different but related matter: have I overlooked something, or does
OpenNETCF not currently have a way of enumerating processes? If that's
correct, is there any reason for it other than no-one's done it yet?
It's definitely possible using Process32First/Process32Next with the
results of a CreateToolhelp32Snapshot call.
somewhat wrong to me. In particular, it calls
OpenProcess (0, false, this.Handle)
but this.Handle is actually the result of calling OpenProcess in the
first place with the process ID.
Should the code not just call (after checking for exit etc)
TerminateProcess (Handle, 0);
? Why the two levels of OpenProcess? The last parameter of OpenProcess
is a DWORD, not a HANDLE, which also suggests there's something wrong.
On a different but related matter: have I overlooked something, or does
OpenNETCF not currently have a way of enumerating processes? If that's
correct, is there any reason for it other than no-one's done it yet?
It's definitely possible using Process32First/Process32Next with the
results of a CreateToolhelp32Snapshot call.