Crashing Windows 95 with GlobalLock() & IDE

Does anyone have any suggestions about the following problem?

I am using the Visual Writer 2.25 DLLs with Delphi, and I am importing and
exporting an RTF buffer.  To do so, I use the GlobalAlloc, GlobalLock (to
get a pointer, then I assign RTF values to the buffer, send the message,
then I call GlobalUnlock, and GlobalFree.

Here's the rub: It runs fine without the IDE.  It will also run fine ONCE
within the IDE.  When I try a second time, the whole machine hangs on the
GlobalLock - Illegal operation - Close. (Then it hangs)

Again, this is Windows 95.

Any ideas are much appreciated.

Thanks