Click to See Complete Forum and Search --> : Multiple definition problems


DotNetter
December 29th, 2005, 10:00 AM
Hi fellows.

I'm using directX with Dev-C++ 4.9.9.2. I want to play mp3 files but I have these problems:

multiple definition of `IID_IMediaEvent'
first defined here
multiple definition of `IID_IMediaControl'
first defined here
multiple definition of `CLSID_FilterGraph'
first defined here
multiple definition of `CLSID_FilgraphManager'
first defined here


The definitions of the IID_IMediaEvent and IID_IMediaControl are in the control.h of DirectX. The CLSID_FilterGraph and CLSID_FilterGraphManager are in the uuids.h If I comment the lines that cause this problem I obtain these problems:

59 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `IID_IMediaControl' undeclared (first use this function)
60 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `IID_IMediaEvent' undeclared (first use this function)
50 C:\Documents and Settings\Alex\Desktop\DirectSound\DirectMain.cpp `CLSID_FilterGraph' undeclared (first use this function)


What I want to know is: Is there another place when this definitions are defined beyond these headers? I'm searching in another DirectX headers and I not found anything.
Can anyone helps? Below the beginning of my code. Thanks a lot for the support:

#define INITGUID
#include <dmusici.h>
#include <dsound.h>
#include <dshow.h>
#include <iostream>

IGraphBuilder* g_pMediaGraph = NULL;
IMediaControl* g_pMediaControl = NULL;
IMediaEvent* g_pMediaEvent = NULL;

LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE h1, HINSTANCE h2, LPSTR lp, int iShow)
{
HWND hwnd;
HDC hdc;
MSG msg;
bool bQuit = false;
WNDCLASSEX wnd;
wnd.cbSize = sizeof(WNDCLASSEX);
wnd.style = CS_OWNDC;
wnd.cbClsExtra = 0;
wnd.cbWndExtra = 0;
wnd.hInstance = h1;
wnd.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wnd.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wnd.hCursor = LoadCursor(NULL, IDC_ARROW);
wnd.lpszMenuName = NULL;
wnd.lpszClassName = "hwnd";
wnd.lpfnWndProc = WindowProcedure;
wnd.hbrBackground = CreateSolidBrush(RGB(128,128,128));
if(!RegisterClassEx(&wnd))
{
MessageBox(0,"não registrou","",0);
}
hwnd = CreateWindowEx(0, "hwnd", "lalala", WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), HWND_DESKTOP, NULL, h1, NULL);
ShowWindow(hwnd, 1);
CoInitialize(NULL);
HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void**)&g_pMediaGraph);
//if(hr != S_OK)
//{
// MessageBox(0,"","caralho",MB_OKCANCEL);
//}
WCHAR wstrFileName[MAX_PATH+1] = L"C:/Documents and Settings/Alex/My Documents/2_Shaaman-Shaman-Angra-Reason-More.mp3";
g_pMediaGraph->QueryInterface(IID_IMediaControl, (void**)&g_pMediaControl);
g_pMediaGraph->QueryInterface(IID_IMediaEvent, (void**)&g_pMediaEvent);
g_pMediaGraph->RenderFile(wstrFileName, NULL);
while(!bQuit)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
{
bQuit = true;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
}

LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_KEYDOWN:
{
switch(wParam)
{
case VK_ESCAPE:
{
g_pMediaControl->Release();
g_pMediaGraph->Release();
CoUninitialize();
PostQuitMessage(0);
break;
}
}
break;
}
case WM_CHAR:
{
switch(wParam)
{
case 'x':
{
g_pMediaControl->Stop();
break;
}
case 'z':
{
g_pMediaControl->Run();
}
}
break;
}
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}