我在VC++6.0下编译DirectX9.0范例为何一直出错?我运行directX 目录bin 中的编译完的例子都正常,但自己编译总出同样错误。我将DirectX9.0的范例AMCap加入到新建立的空的Win32 console的空的工程文件中我已经把Include files和Library files放置在vc++6.0/tools/option/directories设置的最上面开头,还不通过,请问是啥原因?一个简单的范例代码如下:
// emptycon.cpp : Defines the entry point for the console application.
//#include "stdafx.h"
#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(); }错误如下:
include\strmif.h(1018) : error C2146: syntax error : missing ';' before identifier 'HSEMAPHORE'
\include\strmif.h(1018) : fatal error C1004: unexpected end of file found如果把#include<Dshow.h>与#include "stdafx.h"调换位置,错误变为:
F:\test\emptycon\emptycon.cpp(9) : error C2065: 'IGraphBuilder' : undeclared identifier
F:\test\emptycon\emptycon.cpp(9) : error C2065: 'pGraph' : undeclared identifier
F:\test\emptycon\emptycon.cpp(9) : error C2106: '=' : left operand must be l-value
F:\test\emptycon\emptycon.cpp(10) : error C2065: 'IMediaControl' : undeclared identifier
F:\test\emptycon\emptycon.cpp(10) : error C2065: 'pControl' : undeclared identifier
...........................请高手帮忙,谢谢。
// emptycon.cpp : Defines the entry point for the console application.
//#include "stdafx.h"
#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(); }错误如下:
include\strmif.h(1018) : error C2146: syntax error : missing ';' before identifier 'HSEMAPHORE'
\include\strmif.h(1018) : fatal error C1004: unexpected end of file found如果把#include<Dshow.h>与#include "stdafx.h"调换位置,错误变为:
F:\test\emptycon\emptycon.cpp(9) : error C2065: 'IGraphBuilder' : undeclared identifier
F:\test\emptycon\emptycon.cpp(9) : error C2065: 'pGraph' : undeclared identifier
F:\test\emptycon\emptycon.cpp(9) : error C2106: '=' : left operand must be l-value
F:\test\emptycon\emptycon.cpp(10) : error C2065: 'IMediaControl' : undeclared identifier
F:\test\emptycon\emptycon.cpp(10) : error C2065: 'pControl' : undeclared identifier
...........................请高手帮忙,谢谢。
解决方案 »
- 类的构造函数必须是 public 的吗?为何定义成 private ,编译报错呢?
- [VBS调用COM组件的一点小问题]vbscript 中不支持 automation类型
- CryptAPI私钥导出的问题
- 遇到比较棘手的问题,报出stack flow的错误,请各位快帮帮我啊。
- 100分求一个程序拦截另外一个程序的API例子(APIHOOK).在线等
- 对话框上面显示视图,怎么办?
- 请问win2000下如何用程序判断用户是否管理员?
- 如何将一个Html文件嵌入CHtmlView中?请大侠指点
- 很多人问过这个问题:没有word如何读取Word文档内容到自己的编辑器?或Doc复合文件的结构是什么?没人知道吗?
- 一个大白痴的提问
- 关于visual assist x在中文vc2003下syntax color 无法正常显示,请高人进来指点指点!
- 一个函数中有CoInitialize,就一定要有CoUninitialize吗?可不可以分开?
或者在SDK路径(如果是默认设置的话就是C:\DXSDK\Doc\DirectX9)找DirectX9_c.chm查找或者在索引中输入 Compiling DirectX Samples and Other DirectX Applications
按说明配置你的VC。
可以用 开始菜单-〉程序-〉Microsoft DirectX 9.0 SDK-〉DirectX Sample Browser浏览各个范例。