旗舰版win7系统中GraphEdit执行Loading a Graph From an External Process失败对策

操作系统:旗舰版win7

DirectShow SDK: 9.0

IDE环境:VS2008

以下代码参考MSDN:

 1 HRESULT AddToRot(IUnknown *pUnkGraph, DWORD *pdwRegister) 
 2 {
 3     IMoniker * pMoniker = NULL;
 4     IRunningObjectTable *pROT = NULL;
 5 
 6     if (FAILED(GetRunningObjectTable(0, &pROT))) 
 7     {
 8         return E_FAIL;
 9     }
10     
11     const size_t STRING_LENGTH = 256;
12 
13     WCHAR wsz[STRING_LENGTH];
14     StringCchPrintfW(wsz, STRING_LENGTH, L"FilterGraph %08x pid %08x", (DWORD_PTR)pUnkGraph, GetCurrentProcessId());
15     
16     HRESULT hr = CreateItemMoniker(L"!", wsz, &pMoniker);
17     if (SUCCEEDED(hr)) 
18     {
19         hr = pROT->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE, pUnkGraph,
20             pMoniker, pdwRegister);
21         pMoniker->Release();
22     }
23     pROT->Release();
24     
25     return hr;
26 }
27 
28 void RemoveFromRot(DWORD pdwRegister)
29 {
30     IRunningObjectTable *pROT;
31     if (SUCCEEDED(GetRunningObjectTable(0, &pROT))) {
32         pROT->Revoke(pdwRegister);
33         pROT->Release();
34     }
35 }
36 
37 
38 void main()
39 {
40     IGraphBuilder *pGraph;
41     DWORD dwRegister;
42     HRESULT hr;
43     
44     // Initialize the COM library.
45     hr = CoInitialize(NULL);
46     if (FAILED(hr))
47     {
48         printf("ERROR - Could not initialize COM library\n");
49         return;
50     }
51 
52     // Create the filter graph manager.
53     hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
54         IID_IGraphBuilder, (void **)&pGraph);
55      if(FAILED(hr))
56      {
57         printf("ERROR - CoCreateInstance\n");
58         return ;
59      }
60 
61     hr = AddToRot(pGraph, &dwRegister);
62                     
63     // Rest of the application (not shown).
64     while(1)
65     {
66         Sleep(1000);
67         //break;
68     }
69     
70     RemoveFromRot(dwRegister);
71     pGraph->Release();
72     
73     CoUninitialize();
74 }

【问题】:首先运行上述VC程序,然后打开GraphEdit程序,File->Connect to Remote Graph...->出现对话框Select a remote filter graph to view...,对话框中没有任何内容。

【原因】:Windows SDK中未包含Proppage.dll

其实MSDN说的很清楚了,如下面截图。

【对策】:搜索proppage.dll发现几个地方都有proppage.dll,选择C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin下面的proppage.dll,在命令行窗口执行

cd C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin

regsvr32 proppage.dll

将proppage.dll注册到Windows SDK即可。

【验证】接下来重新执行上面的步骤:首先运行上述VC程序,然后打开GraphEdit程序,File->Connect to Remote Graph...->出现对话框Select a remote filter graph to view...,对话框中出现

 

转载于:https://www.cnblogs.com/zhangxiuyuan/p/4413561.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值