Click here to Skip to main content
15,891,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! It's been taking me ages. I've been searching google for a possible solution but up until now I haven't had any clear solution.

When I include Dshow.h in my code I get an error.
When I put #define WINVER 0x0400 in my code the error disappears, but I don't want to do that. Are there any other ways?
Changing the WINVER to 0x0400 or higher does not work.

I am currently using OpenRTM framework and I think this has something to do with the issue. I tried making a new project, just the normal one, and the dshow included fine, but with the OpenRTM framework it does not.

This is included in the service port header.
C++
#include <Windows.h>
#include <DShow.h>


Error 7 error C2061: syntax error : identifier 'HMONITOR' C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ddraw.h

My OS is Windows 7 64bit and I'm using VC++ 2010 for 32bit.

EDIT: Updated the question.
Posted
Updated 20-Nov-14 15:08pm
v4

you can do solve it with a own definition:

#define HMONITOR HANDLE

But to be clear: it is a workaround.
 
Share this answer
 
You need to include "Windows.h" before your DirectX includes. The declaration of HMONITOR is in Windef.h, which is automatically included by Windows.h.
 
Share this answer
 
Comments
Jake Santiago 20-Nov-14 5:15am    
Sorry, I forgot to mention that I already imported windows.h too; before dshow.h.

I tried checking windef.h, and I saw this:
#if(WINVER >= 0x0500)
#ifndef _MAC
DECLARE_HANDLE(HMONITOR);
#endif
DECLARE_HANDLE(HUMPD);
#endif /* WINVER >= 0x0500 */

so tried to add WINVER=0x0500 in the project properties, still failed.
Richard MacCutchan 20-Nov-14 7:11am    
WINVER should be set automatically if you are using Visual Studio. I just created a new project, added "Dshow.h" and it compiled fine. Maybe you should show us the header of your compilation unit. Please edit your question and add the information there.
Jake Santiago 20-Nov-14 21:11pm    
I updated my question. I am using OpenRTM. You are right, I tried making a new project and it's working fine. But I don't know why it won't work with my OpenRTM.
Richard MacCutchan 21-Nov-14 3:39am    
Sorry, never heard of OpenRTM.
Most of the Windows API and SDK header files require that WINVER and/or _WIN32_WINNT are defined. Some header files will set these to defaults or from other definitions when missing.

To be safe you should always set the definitions in a global place to be used for all source files. You can add them to your project settings or to a project specific include file that is included first in all source files. See also Using the Windows Headers[^] in the MSDN.
 
Share this answer
 
Comments
Jake Santiago 20-Nov-14 5:16am    
I tried adding WINVER=0x0500 in the project properties, the error is still there. :(
Jochen Arndt 20-Nov-14 5:36am    
I'm not sure if it helps but you may try a higher version like 0x0600 (Vista). 0x0500 is Windows 2000.
Did you also set _WIN32_WINNT?
EDIT:
Forget the above. You are using a 64 bit build!
I did not have the v7.0A SDK installed here so I can not check this:
Open your ddraw.h file, locate the HMONITOR occurences, and check the conditions (especially for 64-bit builds).
Richard MacCutchan 20-Nov-14 5:22am    
I never have these defined, just let them select the default values.
Jochen Arndt 20-Nov-14 5:33am    
The default values may be too low when using older VS and functions that require a newer Windows version. But you are right, in most cases the default values would do it.
I don't know why Dshow does not work, but I shifted to using MMSystem's mciSendString command. I guess that's better because it's easier to understand without much object creation.

Thanks for all those who tried to help. :D

C++
#include <mmsystem.h>

...

snippet:

std::string playCommand = "open music.mp3 type mpegvideo alias media";
mciSendString(playCommand.c_str(), NULL, 0, 0);
playCommand = "play media from 0";
mciSendString(playCommand.c_str(), NULL, 0, 0);</mmsystem.h>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900