在GraphEdit中显示应用程序的Filtergraph的方法

文章作者 100test 发表时间 2007:10:24 12:50:41
来源 100Test.Com百考试题网


GraphEdit can load a filter graph created by an external process. With this feature, you can see exactly what filter graph your application builds, with only a minimal amount of additional code in your application.
The application must register the filter graph instance in the Running Object Table (ROT). The ROT is a globally accessible look-up table that keeps track of running objects. For information about how your application can add its filter graph to the ROT, see the topic Loading a Graph From an External Process in the Microsoft DirectShow documentation.
To use this feature, perform the following steps:
Compile your application with code that adds a ROT entry for the filter graph.
Run GraphEdit.
Run your application.
In the File menu, click Connect to Remote Graph....
In the Select a remote filter graph to view... dialog box, 0select the process ident
ifier (pid) of the second application.
Click OK.
To refresh the list of process identifiers, click Refresh in the dialog box.
注意这只能在2000和XP下能用。
下面是将你在应用程序中的Filter Graph添加到ROT的代码,
HRESULT AuGraph::AddToRot(IUnknown *pUnkGraph, DWORD *pdwRegister)
{
HRESULT hr = NOERROR.
IMoniker * pMoniker = NULL.
IRunningObjectTable * pROT = NULL.
if(FAILED(GetRunningObjectTable(0,&.pROT)))
{
return E_FAIL.
}
WCHAR wsz[256].
::memset(wsz,0,256).
//wsprintfW(wsz,L"PID: x IGraphFilter = x",(DWORD_PTR)pUnkGraph,GetCurrentProcessId()).

hr = StringCchPrintfW(wsz, NUMELMS(wsz), L"FilterGraph x pid x",
(DWORD_PTR)pUnkGraph,GetCurrentProcessId()).
hr = CreateItemMoniker(L"!",wsz,&.pMoniker).
if(SUCCEEDED(hr))
{
hr = pROT->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE,pUnkGraph,pMoniker,pdwRegister).
pMoniker->Release().
}
pROT->Release().
return hr.
}
下面是在我们使用了之后要除掉它的代码:
void AuGraph::RemoveFromRot(DWORD pdwRegister)
{
IRunningObjectTable *pROT = NULL.
if(SUCCEEDED(GetRunningObjectTable(0,&.pROT)))
{
pROT->Revoke(pdwRegister).
pROT->Release().
}
}
在我们整个应用程序中的代码结构如下:
hr = CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC_SERVER,
IID_IGraphBuilder,(void **)&.m_pGB).
if(FAILED(hr))
{
return hr.
}
#ifdef _DEBUG
hr = AddToRot(m_pGB,&.dwRegister).
#endif
.............应用程序
#ifdef _DEBUG
RemoveFromRot(dwRegister).
#endif
if(m_pGB)
m_pGB = NULL.

看我的运行结果




当然我们有时候,可能有错误,但我们要有耐心,多弄几次。就可以看到了啊



相关文章


c_c 语言实现堆栈修改,通过ret跳转到自定义函数
C 类型转换运算符的使用方法
在GraphEdit中显示应用程序的Filtergraph的方法
C 私有成员变量的访问权限研究
VC 编译选项说明
防止窗口闪烁的方法
灵活使用GOTO语句
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛