码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2015-04-10 09:26:37      阅读:286      评论:0      收藏:0      [点我收藏+]

标签:

操作系统:旗舰版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...,对话框中出现

技术分享

 

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

标签:

原文地址:http://www.cnblogs.com/zhangxiuyuan/p/4413561.html

(0)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!