xp下directshow开发环境的建立

找了一下网上的资料,记录下来备忘

操作系统:windows XP SP3

开发环境:visual c6.0

由于从2004年夏季发布的directxc sdk开始不再集成directshow,所以我们要到网上下载directxb sdk, 约220M。

1.编译BaseClasses

安装后把目录切换到X:\DXSDK\Samples\C++\ DirectShow\BaseClasses (X是directx sdk安装时所选的分区,)用vc6.0打开baseclasses.dsw,编译后会生成一个Debug_Unicode文件夹,里面有个strmbasd.lib,等下会用到这个文件。

2.设置库文件位置

打开vc6.0,点击tool--options--Directories,在Directories下添加目录位置:X:\DXSDK\Include,                                                              和                     X:\DXSDK\SAMPLES\C++\DIRECTSHOW\BASECLASSES 

3.添加链接文件 strmbasd.lib

打开vc6.0,点击project--settings--links,在Object/Library Modules栏添加“strmbasd.lib”(不要引号)。               

下面是个简单的测试程序:

#include <dshow.h>
#include <stdio.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.mp3", NULL);

 printf( "example.mp3 is running!!\n");

    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();
}
 

你可能感兴趣的:(XP,sdk,配置环境,directshow,directxb)