Is it safe to call GetProcessHeap at the start of an application then use the same handle through the run of the program or is there a possibility of the handle value changing for some reason ? For now I am assuming that it is static for the life of the process but I just want to make sure.
Posted on 2004-04-12 15:59:43 by donkey
I've been wondering about this myself, and I haven't come across any information either for or against.

I assume it would be safe to get it at program start - I can't think of a reason it would break - I can't think of any time where a handle value would change, even in win16 with the Global/Local memory stuff the handle value would be constant, while the memory pointer returned on lock could change around (well, I think - I only did very very little win16 coding).

As far as I remember, you cannot destroy the process heap either, so... it 'feels safe' to get the handle at program startup, it's not one of these very dirty things that depend much on windows internals (hardcoding hInstance et cetera).

Also, if apps are done correctly, it will not be too much a bother fixing to always call GetProcessHeap, if it *does* break sometime - whether you have the source or not :)
Posted on 2004-04-12 16:24:12 by f0dder
Yeah, that's basically how I see it as well. The only thing I could find on the subject was in an article concerning HeapCreate at MSDN:

A possible use for the heap functions is to create a private heap when a process starts up, specifying an initial size sufficient to satisfy the memory requirements of the process
Posted on 2004-04-12 16:33:55 by donkey