Archived

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

CoInitializeEx

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
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 this post


Link to post
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"?

Share this post


Link to post
Share on other sites