how come we need not close the handle returned by ShellExecute ?

Posted by fred-hh on Stack Overflow See other posts from Stack Overflow or by fred-hh
Published on 2010-05-06T10:41:50Z Indexed on 2010/05/06 10:48 UTC
Read the original article Hit count: 268

Filed under:
|

On success, ShellExecute returns a handle.

Do we need to close this handle, and if so, how ?

According to examples published my Microsoft, we need not close this handle. But the doc of ShellExecute itself is mute on the subject. Can you confirm we indeed do not need to close this handle ?

But then, how can a handle be valid and in no need of being closed ??? Which of the following statements is/are true:

  1. the handle is invalid and we can't do anything with it;
  2. the handle is never freed and there is a (Microsoft-sponsored) memory leak (until the caller program ends);
  3. the handle is automatically freed by the system at some time and never reused afterwards (-> another kind of resource leak). Only on trying to use it can we know whether it still points to something.
  4. what else ?

© Stack Overflow or respective owner

Related posts about winapi

Related posts about shellexecute