我在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
...........................请高手帮忙,谢谢。

解决方案 »

  1.   

    加入Strmiids.lib文件#pragma comment(lib,"Strmiids.lib")
      

  2.   

    高人啊我想问一下。 #pragma once 什么意思啊。? !!!谢谢了。
      

  3.   

    是否安装DX9SDK?并到微软去升级到最新的SDK
      

  4.   

    好象不管用,前面错误出现在编译过程中,还没有到连接过程。我用VC++6.0生成hello框架,然后将上面代码拷贝到cpp中。
      

  5.   

    #pragma once 是表示文件只包含一次Library files是需要用#pragma comment的方式添加,或者project-->setting->link->object/library写入文件
      

  6.   

    安装DirectX9.0 SDK后,在开始菜单-〉程序-〉Microsoft DirectX 9.0 SDK下有一个DirectX Documentation for C++
    或者在SDK路径(如果是默认设置的话就是C:\DXSDK\Doc\DirectX9)找DirectX9_c.chm查找或者在索引中输入 Compiling DirectX Samples and Other DirectX Applications
    按说明配置你的VC。
      

  7.   

    另外,SDK中自带了Sample Projects,按上面的方法设置后,直接打开工程文件就可以编译了。
    可以用 开始菜单-〉程序-〉Microsoft DirectX 9.0 SDK-〉DirectX Sample Browser浏览各个范例。
      

  8.   

    SDK Direct Show文挡中说在 Sample 目录中有 Dshow.dsw 但是在中Sample 目录中没有这个文件,哪位有 Dshow.dsw 或 Capture.dsw文件,我想编译 AMcapture 或Captexture 范例。