Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CoInitializeEx

91 views
Skip to first unread message

Alan Hoyt

unread,
Sep 23, 1999, 3:00:00 AM9/23/99
to
Hi,

I'm using Win NT 4.0 with VC++ 6.0.
I'm having problems getting a program to compile that has a call to
CoInitializeEx(NULL, COINIT_MULTITHREADED );

I need this call in my thread procedure to make all my threads belong to the
same apartment, so I don't have to marshal interface pointers across
apartment boundaries. I've included the header file objbase.h that is
listed in the MSDN docs for the function, but I still get the following
compile errors:

C:\work\ADOThreadTest\readThread.cpp(58) : error C2065: 'CoInitializeEx' :
undeclared identifier

C:\work\ADOThreadTest\readThread.cpp(58) : error C2065:
'COINIT_MULTITHREADED' : undeclared identifier

If I replace CoInitializeEx with CoInitialize the program will compile with
no problems. Are there any other headers that I have to include, or
compiler defines that I have to declare to make this compile? Is there
another way to make all my threads belong to the same apartment besides
using CoInitializeEx?

Thanks,

Alan

Peter Partch

unread,
Sep 23, 1999, 3:00:00 AM9/23/99
to
Define _WIN32_DCOM (in your project settings pre-processor defines).

The API's specific to DCOM release of the OS are surrounded by conditional
compilation statements that require you to #define to access there
definitions...

Peter Partch

Alan Hoyt <al...@delorme.com> wrote in message
news:uAoOz4fB$GA.278@cppssbbsa04...

none

unread,
Sep 23, 1999, 3:00:00 AM9/23/99
to
Thanks Peter, that did the trick.

Stefan Cuypers

unread,
Sep 25, 1999, 3:00:00 AM9/25/99
to
Alan,

Since CoInitializeEx is a new function in NT 4, it is protected by
conditional compilation.
You need to tell the header files you're targeting NT 4 or later.
If you're using an stdafx.h file, put the following lines on it before
including any of the system headers (this is what the ATL wizzard does) :
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif

If you don't have an stdafx.h file, you can put the define in your project
settings.

regards,
Stefan Cuypers

0 new messages