I can see how to do the initilization and Exit code for a DLL..... but I am confused. This code is the code itself which windows wont even unload. What I want is to initialise each instance. In my usage I want the DLL to open a serial port which needs to be closed when the application dies. Another application may open a different port or use USB or tcpip etc.