第一个DirectShow程序

 1: // DShowTest.cpp : 定义控制台应用程序的入口点。
 2: //
 3: 
 4: #include "stdafx.h"
 5: 
 6: 
 7: #include <dshow.h>
 8: void main(void)
 9: {
10: 	IGraphBuilder *pGraph = NULL;
11: 	IMediaControl *pControl = NULL;
12: 	IMediaEvent   *pEvent = NULL;
13: 
14: 	// Initialize the COM library.
15: 	HRESULT hr = CoInitialize(NULL);
16: 	if (FAILED(hr))
17: 	{
18: 		printf("ERROR - Could not initialize COM library");
19: 		return;
20: 	}
21: 
22: 	// Create the filter graph manager and query for interfaces.
23: 	hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, 
24: 		IID_IGraphBuilder, (void **)&pGraph);
25: 	if (FAILED(hr))
26: 	{
27: 		printf("ERROR - Could not create the Filter Graph Manager.");
28: 		return;
29: 	}
30: 
31: 	hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
32: 	hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
33: 
34: 	// Build the graph. IMPORTANT: Change this string to a file on your system.
35: 	hr = pGraph->RenderFile(L"D://TDDOWNLOAD//Movie//回梦游仙-千年缘.avi", NULL);
36: 	if (SUCCEEDED(hr))
37: 	{
38: 		// Run the graph.
39: 		hr = pControl->Run();
40: 		if (SUCCEEDED(hr))
41: 		{
42: 			// Wait for completion.
43: 			long evCode;
44: 			pEvent->WaitForCompletion(INFINITE, &evCode);
45: 
46: 			// Note: Do not use INFINITE in a real application, because it
47: 			// can block indefinitely.
48: 		}
49: 	}
50: 	pControl->Release();
51: 	pEvent->Release();
52: 	pGraph->Release();
53: 	CoUninitialize();
54: }
 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值