first of all ( and for curiosity ), why are you using GlobalAlloc ? ( instead of the standard allocation functions and/or the Windows heap allocation APIs )