这个
documentation on BindToObject
建议您可以使用创建绑定上下文
CreateBindCtx
并通过:
HRESULT hr; // An error code
IMoniker * pMnk; // A previously acquired interface moniker
// Obtain an IBindCtx interface.
IBindCtx * pbc;
hr = CreateBindCtx(NULL, &pbc);
if (FAILED(hr)) exit(0); // Handle errors here.
// Obtain an implementation of pCellRange.
ICellRange * pCellRange;
hr = pMnk->BindToObject(pbc, NULL, IID_ICellRange, &pCellRange);
if (FAILED(hr)) exit(0); // Handle errors here.
// Use pCellRange here.
// Release interfaces after use.
pbc->Release();
pCellRange->Release();
接口仅描述对象必须支持的行为,而不描述如何需要它来支持它。一方面,实现对象可能需要在绑定上下文中传递,也可能不需要。由于您所指的文档省略了它,因此在您的情况下可能不需要它。
另一方面,在我看来,创建一个绑定上下文对象并将其传入并没有什么大不了的。您可以将相同的消息传递给每个呼叫
BindToObject