[comp.windows.ms.programmer] Trouble with standard mode and a DLL

nick@aimed.UUCP (Nick Pemberton) (04/07/91)

Greetings All.

I have a problem that I just can't seem to find a reference to in the
SDK Docs. Its quite possible that the answer is so obvious that it
doesn't deserve to be in print, however, I am new at windows
programming.

I am trying to develop a DLL that provides a number of applications with
a generic read/write interface to a remote PICK based host, using a
serial port. Development has gone well, and I have a working prototype. Or
thought I had. I have developed this on a 386 box, running in enhanced
mode. Until yesterday, I thought all was well, but when I loaded it
onto a 286, running in standard mode, the DLL crashes the machine on exit.
It does the same thing on the 386 if run in standard mode.

I have narrowed it down to a specific section of code that is killing it.
When all applications exit that are using the DLL, the DLL is also
destroyed, as layed out in the SDK docs. In my WEP procedure, I want to
check an internal data structure that tells me if the remote hosts have
been left in a connected state when the applications exited. If they have,
I want to send a command to them telling them to close down. I send a
STOP message over the appropriate serial port using WriteComm(), and wait
for a moment to allow the serial port to transmit the command before
calling FlushComm and CloseComm to release things back to windows. If I
comment out the WriteComm command, the DLL works just fine on a 286.

Any ideas what I've done wrong? What is the difference between standard
and enhanced mode that lets WriteComm() work in the shutdown stages of
a DLL in 386 enhanced mode? Incidently, the serial communications work
fine in 286 mode during the normal lifespan of the DLL; its just on shutdown
that it gets in trouble. 

Using Codeview, I've been able t