在DirectX9里提供的一个例子
#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();
}编译时会出错。
directshow1.obj : error LNK2001: unresolved external symbol _IID_IMediaEvent
directshow1.obj : error LNK2001: unresolved external symbol _IID_IMediaControl
directshow1.obj : error LNK2001: unresolved external symbol _CLSID_FilterGraph
directshow1.obj : error LNK2001: unresolved external symbol _IID_IGraphBuilderinclude和lib的路径已设好了。
请问还有可能哪里出错,谢谢

解决方案 »

  1.   

    include和lib的路径已设好了。
    ________________要放到其他路径之前。
      

  2.   

    #include <dshow.h>
    #pragma comment(lib,"Strmiids.lib")
      

  3.   

    谢谢大家,我已经把路径放到其他路径之前了。为什么要加#pragma comment(lib,"Strmiids.lib")?
      

  4.   

    lib里:
    D:\DXSDK\Lib
    D:\DXSDK\SAMPLES\C++\DIRECTSHOW\BASECLASSES\DEBUG
    D:\DXSDK\SAMPLES\C++\DIRECTSHOW\BASECLASSES\RELEASE
    include里:
    D:\DXSDK\INCLUDE
    d:\DXSDK\SAMPLES\C++\DIRECTSHOW\BASECLASSES都加好了
      

  5.   

    谢谢大家,我已经把路径放到其他路径之前了。为什么要加#pragma comment(lib,"Strmiids.lib")?_________________
    路径添加了只是表示要在这个路径里边去搜索.h和.lib文件,但是编译器不知道你需要使用哪个.h和.lib文件。
    #pragma comment(lib,"Strmiids.lib")
    就是指定需要连接的lib文件,就像
    #include <dshow.h>
    指定需要包含的头文件一个道理。
      

  6.   

    解决了,我看directshow的例子也没有用到#pragma comment(lib,"Strmiids.lib")
    所以问下,谢谢各位