Hi,

I have this:

if (CreateProcess(.......)) {
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
}

Is CloseHandle really required in this case? If missing, what will happen?

Lisa

Re: CreateProcess question by Michael

Michael
Sun Jan 14 19:43:41 CST 2007

Yes, it's really required. It's required that you close all handles you
open. If you don't close it, you'll leak whatever memory the kernel
allocated to manage the process (a process data structure). Same with the
thread data structure it allocated (if you don't close the thread handle).

--
Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com


"Lisa Pearlson" <no@spam.plz> wrote in message
news:env0AfDOHHA.320@TK2MSFTNGP06.phx.gbl...
> Hi,
>
> I have this:
>
> if (CreateProcess(.......)) {
> WaitForSingleObject(pi.hProcess, INFINITE);
> CloseHandle( pi.hProcess );
> CloseHandle( pi.hThread );
> }
>
> Is CloseHandle really required in this case? If missing, what will happen?
>
> Lisa
>