Skip to main content
gamedev.net
🔒 Locked

CoInitializeEx

Started by amish1234 Oct 12, 2003 at 3:07 AM 6 replies 3.3k views
Original Post
amish1234
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]
___________________________________________________________Where to find the intensity (Updated Dec 28, 2004)Member of UBAAG (Unban aftermath Association of Gamedev)
Jonathan Steed
Jonathan Steed
Add _WIN32_DCOM to your preprocessor definitions.

- 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
========================Jonathan SteedSoftware Design EngineerWindows Graphics and Gaming TechnologiesMicrosofthttp://blogs.msdn.com/jsteedThis posting is provided "AS IS" with no warranties, and confers no rights
amish1234
amish1234
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();
}
___________________________________________________________Where to find the intensity (Updated Dec 28, 2004)Member of UBAAG (Unban aftermath Association of Gamedev)
Jonathan Steed
Jonathan Steed
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
========================Jonathan SteedSoftware Design EngineerWindows Graphics and Gaming TechnologiesMicrosofthttp://blogs.msdn.com/jsteedThis posting is provided "AS IS" with no warranties, and confers no rights
Vulcan
Vulcan
Try making sure your app is linking with the multithreaded libraries also. And make sure that define is before your #inculdes.

-Eric
LordShade
LordShade
Add this to your stdafx.h file:

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif
amish1234
amish1234
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.
___________________________________________________________Where to find the intensity (Updated Dec 28, 2004)Member of UBAAG (Unban aftermath Association of Gamedev)
laserbeams
laserbeams
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"?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.