Path: utzoo!attcan!ncrcan!ziebmef!mikek From: mikek@ziebmef.uucp (Mike King) Newsgroups: comp.windows.ms Subject: Spawning in Windows Keywords: spawn exec Message-ID: <1989May19.112713.17785@ziebmef.uucp> Date: 19 May 89 15:27:12 GMT Organization: Ziebmef Public Access Unix, Toronto, Canada Lines: 24 Recently I posted an article asking for help spawning other apps from within a Windows app. I received a number of mail responses and I tried out all of the suggestions. Since I've seen others asking the same question as I did I thought I would present my findings. 1 - spawn? from the standard library will work --- most of the time! Sometimes it seems to crash in a nasty way. 2 - using DOS function 4B works --- most of the time! Sometimes it will crash as well, usually with ENOMEM. 3 - the winning suggestion was received from Microsoft, and confirmed by someone from hDC (sorry I forget your name). Here goes: /* reliable Windows spawn code */ GlobalCompact((DWORD)-1); /* compact the global heap */ LockData(0); /* lock down your data segment */ spawnl(P_NOWAIT, "newapp.exe", "newapp", NULL); UnlockData(0); /* unlock your data segment */ The interesting bits are the GlobalCompact - to give yourself some room, and the LockData - stop data pointers from becoming orphans.