OpenNETCF: Bug in Process.Kill?

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.
 
J

Jon Skeet [C# MVP]

Alex Feinman said:
I don't think we have enumeration code as a part of the library, but Alex
Yakhnin has it in one of his early articles on MSDN
http://msdn.microsoft.com/library/en-us/dnnetcomp/html/ProcessManager.asp

Yup, found that :)

I won't actually need all of it - just name and process ID - but I
thought I'd ask in case I'd missed it.

Any comment on whether or not I've found a bug in Process.Kill? Chances
are I'm missing something, but...
 
P

Peter Foot [MVP]

It's quite possible. I'll take a look at the latest code and get back to
you.

With regards enumerating processes this should be in SDF v1.2 in the
OpenNETCF.Toolhelp namespace, this doesn't yet fit with the object model
used on the full framework (integral to the Process class) but wraps all the
necessary toolhelp APIs

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
 
J

Jon Skeet [C# MVP]

Peter Foot said:
It's quite possible. I'll take a look at the latest code and get back to
you.

With regards enumerating processes this should be in SDF v1.2 in the
OpenNETCF.Toolhelp namespace, this doesn't yet fit with the object model
used on the full framework (integral to the Process class) but wraps all the
necessary toolhelp APIs

Aha - excellent, thanks very much :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top