#### Archived

This topic is now archived and is closed to further replies.

# CoInitializeEx

This topic is 5169 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm learning DirectPlay. In the first tutorial, COM is initialized by calling
CoInitializeEx(NULL, COINIT_MULTITHREADED);
In my (console) app I get an undeclared identifier on this function call. (Both the function and COINIT_MULTITHREADED are undeclared identifiers). I included every header file that tutorial 1 includes, except for its resource.h. WTF??? I looked through the help, and I can't find anything that says what header files I need to include for this function or for COM functions in general. The VC++7 help had a link to the MSDN page for this function, which was, of course, unavailable ATM or some shit. I used the function CoInitialize in an app that used DirectShow. I didn't have to include any header files specifically for COM there. It's 1:00 AM. Maybe this is the start to a very bad day. EDIT: I found out that the function prototype for CoInitializeEx is in objbase.h, but including that didn't do anything. [edited by - amish1234 on October 12, 2003 4:11:14 AM] [edited by - amish1234 on October 12, 2003 4:15:16 AM]

##### Share on other sites

- Jon

========================
Jonathan Steed
Software Design Engineer
Windows Graphics and Gaming Technologies
Microsoft

This posting is provided "AS IS" with no warranties, and confers no rights

##### Share on other sites
I even tried that, but forgot to mention it.

Here''s the code so you know I''m not doing anything retarded. I apologize for the use of goto. It was copied and pasted from the tutorial code.

void main(){	HRESULT hr = S_OK;		InitCommonControls();	CoInitializeEx(NULL, COINIT_MULTITHREADED);		if( FAILED( hr = InitDirectPlay() ) )    {        cout << "Failed to initialize DirectPlay.  This app will now self destruct" << endl;        goto LCleanup;    }	LCleanup:    CleanupDirectPlay();    CoUninitialize(); }

##### Share on other sites
Are you using the Visual Studio projects included with the SDK? If you''re starting from an empty project but the bundled projects compile OK then just check to make sure your includes, defines, and libraries match. When I removed the _WIN32_DCOM definition from a working DirectPlay sample I got the exact same errors you''re getting, so I thought for sure that was it.

- Jon

========================
Jonathan Steed
Software Design Engineer
Windows Graphics and Gaming Technologies
Microsoft

This posting is provided "AS IS" with no warranties, and confers no rights

-Eric

##### Share on other sites

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif

##### Share on other sites
Got it working now, thanks guys.

The problem was that the #define _WIN32_DCOM was after the inlcudes. Then I had one unresolved external, found the lib file pretty quickly.

I''m this happy:

:-)

Proceeding on a brutal rampage is the obvious choice.

##### Share on other sites
quote:
Original post by amish1234
I''m learning DirectPlay. In the first tutorial, COM is initialized by calling
CoInitializeEx(NULL, COINIT_MULTITHREADED);

In my (console) app I get an undeclared identifier on this function call. (Both the function and COINIT_MULTITHREADED are undeclared identifiers). I included every header file that tutorial 1 includes, except for its resource.h. WTF???

I looked through the help, and I can''t find anything that says what header files I need to include for this function or for COM functions in general. The VC++7 help had a link to the MSDN page for this function, which was, of course, unavailable ATM or some shit.

I used the function CoInitialize in an app that used DirectShow. I didn''t have to include any header files specifically for COM there.

It''s 1:00 AM. Maybe this is the start to a very bad day.

EDIT: I found out that the function prototype for CoInitializeEx is in objbase.h, but including that didn''t do anything.

[edited by - amish1234 on October 12, 2003 4:11:14 AM]

[edited by - amish1234 on October 12, 2003 4:15:16 AM]

Can I ask you a quetion. Are you using VS.NET? Actually, in order to use the CoInitializeEx, what do you need to add at the "Add Reference"?

• 37
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631360
• Total Posts
2999553
×