Re: Dealing with HANDLEs
- From: adebaene@xxxxxxxxxxxxxxxx
- Date: 1 Dec 2006 01:10:38 -0800
On 1 déc, 09:28, "Pavel Lebedinsky [MSFT]" <p...@xxxxxxxxxxxxxxxxxxxx>
wrote:
"Arnaud Debaene" wrote:
Think more about it : Are you sure you want your "Process" class to be
copiable? A process is a unique entity, with it's own identity (it's
ProcessID), which can't be duplicated : the closest thing to copying a
process is forking it, which is quite unnnatural on Windows and is NOT a
mere copy.
It should be the same thing with your class : it shouldn't be copiable In
that case, making it's copy constructor private and undefined should do
the trick.
Now, if your class is more a "ProcessInformation" than a "Process", andhas its own flags that can be set with SetHandleInformation for
you really want to be able to copy it, DuplicateHandle is the way to go
(in both the copy constructor and the asignement operator).Duplicated handles are not necessarily interchangeable. Each handle
example. The actual numeric value of the handle is also often used
for things like tracing/debugging, or even passing it as a command
line argument to child processes (for inheritable handles).
So I don't think using DuplicateHandle in a copy constructor or
operator= is a good idea. I would just make this class non-copyable.
I agree. It is coherent with the fact, that, if the class is really a
"ProcessInformation" class, there is no need for it to hold a handle to
the process as a data member (the handle should be opened just when
needed, in order to call APIs, then closed immediatly).
Arnaud
MVP - VC
.
- Follow-Ups:
- Re: Dealing with HANDLEs
- From: Jake Forson
- Re: Dealing with HANDLEs
- References:
- Dealing with HANDLEs
- From: Ben Menashe
- Re: Dealing with HANDLEs
- From: Arnaud Debaene
- Re: Dealing with HANDLEs
- From: Pavel Lebedinsky [MSFT]
- Dealing with HANDLEs
- Prev by Date: Re: Dealing with HANDLEs
- Next by Date: Re: Access kernel objects in different TS sessions?
- Previous by thread: Re: Dealing with HANDLEs
- Next by thread: Re: Dealing with HANDLEs
- Index(es):
Relevant Pages
|
Loading