Re: Dealing with HANDLEs





On 1 déc, 16:45, "Le Chaud Lapin" <jaibudu...@xxxxxxxxx> wrote:
Jake Forson wrote:
I disagree with both of you. There is nothing intrinsically wrong or harmful
with copying a handle.

I agree, the problem is not a technical one : It is perfectly ok to use
DuplicateHandle as long as you play along the rules, but that's not the
point...
The problem I noticed is about object model : It's just rather
unnatural that a "Process" class is copyable. If there were such a
class, I would expect than, when an instance is duplicated, a new
process is launched (forked) on the system, and I doublt that is what
the OP wants
"Process" is just an identity object, who shouldn't be copyable for
semantic reasons ; as Jake as said, if you need to put them in an STL
collection, use (smart)pointers.

Arnaud
MVP - VC

.



Relevant Pages

  • Re: Dealing with HANDLEs
    ... the closest thing to copying a ... 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. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Dealing with HANDLEs
    ... DuplicateHandle as long as you play along the rules, ... The problem I noticed is about object model: ... semantic reasons; as Jake as said, if you need to put them in an STL ... The technique Jake and I were proposing works for other kernel-mode ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Dealing with HANDLEs
    ... the closest thing to copying a ... you really want to be able to copy it, DuplicateHandle is the way to go ... (in both the copy constructor and the asignement operator). ...
    (microsoft.public.win32.programmer.kernel)