用VC6编译一个DirectShow里的例子程序,功能就是播放一个视频文件,怎么编译不过呀?

wcedever 2010-02-21 09:25:27
用VC6编译一个DirectShow里的例子程序,功能就是播放一个视频文件,怎么编译不过呀?


用VC6编译一个DirectShow里的例子程序,功能就是播放一个视频文件,怎么编译不过呀?

只有一个.c文件comtest.c, 源代码:

#include <dshow.h>

void main(void)
{
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IMediaEvent *pEvent = NULL;

// Initialize the COM library.
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr))
{
printf("ERROR - Could not initialize COM library");
return;
}

// Create the filter graph manager and query for interfaces.
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr))
{
printf("ERROR - Could not create the Filter Graph Manager.");
return;
}

hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);

// Build the graph. IMPORTANT: Change this string to a file on your system.
hr = pGraph->RenderFile(L"C:\\Example.avi", NULL);
if (SUCCEEDED(hr))
{
// Run the graph.
hr = pControl->Run();
if (SUCCEEDED(hr))
{
// Wait for completion.
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);

// Note: Do not use INFINITE in a real application, because it
// can block indefinitely.
}
}
pControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();
}


编译出错:

Compiling...
COMtest.c
e:\test\comtest\comtest.c(33) : error C2115: 'function' : incompatible types
e:\test\comtest\comtest.c(33) : warning C4024: 'CoCreateInstance' : different types for formal and actual parameter 1
e:\test\comtest\comtest.c(34) : error C2115: 'function' : incompatible types
e:\test\comtest\comtest.c(34) : warning C4024: 'CoCreateInstance' : different types for formal and actual parameter 4
e:\test\comtest\comtest.c(41) : error C2039: 'QueryInterface' : is not a member of 'IGraphBuilder'
d:\program files\microsoft platform sdk\include\strmif.h(7458) : see declaration of 'IGraphBuilder'
e:\test\comtest\comtest.c(42) : error C2039: 'QueryInterface' : is not a member of 'IGraphBuilder'
d:\program files\microsoft platform sdk\include\strmif.h(7458) : see declaration of 'IGraphBuilder'
e:\test\comtest\comtest.c(45) : error C2039: 'RenderFile' : is not a member of 'IGraphBuilder'
d:\program files\microsoft platform sdk\include\strmif.h(7458) : see declaration of 'IGraphBuilder'
e:\test\comtest\comtest.c(49) : error C2039: 'Run' : is not a member of 'IMediaControl'
d:\program files\microsoft platform sdk\include\control.h(480) : see declaration of 'IMediaControl'
e:\test\comtest\comtest.c(54) : error C2039: 'WaitForCompletion' : is not a member of 'IMediaEvent'
d:\program files\microsoft platform sdk\include\control.h(777) : see declaration of 'IMediaEvent'
e:\test\comtest\comtest.c(60) : error C2039: 'Release' : is not a member of 'IMediaControl'
d:\program files\microsoft platform sdk\include\control.h(480) : see declaration of 'IMediaControl'
e:\test\comtest\comtest.c(61) : error C2039: 'Release' : is not a member of 'IMediaEvent'
d:\program files\microsoft platform sdk\include\control.h(777) : see declaration of 'IMediaEvent'
e:\test\comtest\comtest.c(62) : error C2039: 'Release' : is not a member of 'IGraphBuilder'
d:\program files\microsoft platform sdk\include\strmif.h(7458) : see declaration of 'IGraphBuilder'
Error executing cl.exe.

COMtest.exe - 10 error(s), 2 warning(s)
...全文
94 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
syz 2011-04-12
  • 打赏
  • 举报
回复
Directxsdk版本问题吧? 你这代码好象是例子里的。
换版本或改代码。
daiweb 2010-02-21
  • 打赏
  • 举报
回复
!!!!!!!!kan kan看看
wshcdr 2010-02-21
  • 打赏
  • 举报
回复
在另外一个帖子里回复你了啊

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧