View Full Version : InitLibrary() is incompatible with MScomm?

June 14, 2011, 02:55:52
I try to use the Microsoft Communication Control (MSComm) in VC2008 to send and receive data through serial port.
But it looks like the IC cannot work with MSComm. If I use the InitLibrary() and MSComm together, the program show that there is a problem in occcont.cpp. While either of they is OK when I use them separately.
How can I solve it ?
Thank you very much.

Stefan Geissler
June 14, 2011, 09:58:52
Many years in VC6 we had a similar problem: Using the IC Classlibary causes lock ups using other ActiveX Controls in the application.


There is a workaround available. Insert in one of the cpp files (i.e the app file) following lines of code:

struct static_init
static_init() { CoUninitialize(); OleInitialize( 0 ); };
#pragma init_seg( user )
static_init sys_init;

June 14, 2011, 17:34:49
I have found a post in 2004 that the author had a similar problem, and he overcome it by the same way. But thank you all the same.
To my surprise, the man who replied the author in 2004 was Stefen, too!
There has been more than 7 years.