本文整理汇总了C++中CreateBindCtx函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateBindCtx函数的具体用法?C++ CreateBindCtx怎么用?C++ CreateBindCtx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CreateBindCtx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FileMonikerImpl_IsEqual
/******************************************************************************
* FileMoniker_IsEqual
*/
static HRESULT WINAPI
FileMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
{
FileMonikerImpl *This = impl_from_IMoniker(iface);
CLSID clsid;
LPOLESTR filePath;
IBindCtx* bind;
HRESULT res;
TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
if (pmkOtherMoniker==NULL)
return S_FALSE;
IMoniker_GetClassID(pmkOtherMoniker,&clsid);
if (!IsEqualCLSID(&clsid,&CLSID_FileMoniker))
return S_FALSE;
res = CreateBindCtx(0,&bind);
if (FAILED(res)) return res;
res = S_FALSE;
if (SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath))) {
if (!lstrcmpiW(filePath, This->filePathName))
res = S_OK;
CoTaskMemFree(filePath);
}
IBindCtx_Release(bind);
return res;
}
示例2: CreateFileMoniker
int BookServerTest::createFileMoniker()
{
ComPtr<IMoniker> moniker;
auto hr = CreateFileMoniker(kFileName, &moniker);
if (FAILED(hr)) {
return -1;
}
IBindCtx* pbc;
CreateBindCtx(0, &pbc);
ComPtr<IBook> book;
hr = moniker->BindToObject(pbc, NULL, IID_IBook, (void**)&book);
if (FAILED(hr)) {
return -1;
}
ComPtr<IStorage> pStorage;
ComPtr<IStream> pStream;
hr = StgCreateStorageEx(kMonikerFileName, STGM_WRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE,
STGFMT_STORAGE, 0, NULL, 0, IID_IStorage, (void**)&pStorage);
if (FAILED(hr))
return hr;
hr = pStorage->CreateStream(kStreamName, STGM_WRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE,
0, 0, &pStream);
if (FAILED(hr))
return hr;
OleSaveToStream(moniker, pStream);
return 0;
}
示例3: CreateBindCtx
HRESULT CDuiAxContainer::MonikerBindToStorage(IMoniker *pMk, IBindCtx *pBC,
IBindStatusCallback *pBSC, REFIID riid, void **ppvObj)
{
HRESULT hr = E_FAIL;
CDuiComPtr<IBindCtx> pBCCtx = pBC;
if (pBCCtx == NULL)
{
// creates it if not present
hr = CreateBindCtx(0, &pBCCtx);
}
if ( pBCCtx != NULL )
{
if ( pBSC != NULL )
{
typedef HRESULT (WINAPI* pfnRegisterBindStatusCallback)( IBindCtx *pbc,IBindStatusCallback *pbsc,IBindStatusCallback **ppbscPrevious,DWORD dwReserved);
HMODULE urlmon = ::GetModuleHandleA("urlmon.dll");
if(!urlmon)
urlmon = ::LoadLibraryA("urlmon.dll");
pfnRegisterBindStatusCallback OrigRegisterBindStatusCallback = (pfnRegisterBindStatusCallback)::GetProcAddress(urlmon,"RegisterBindStatusCallback");
hr = OrigRegisterBindStatusCallback(pBCCtx, pBSC, NULL, 0);
}
hr = pMk->BindToStorage(pBCCtx, NULL, riid, ppvObj);
}
return hr;
}
示例4: ItemMonikerImpl_IsEqual
/******************************************************************************
* ItemMoniker_IsEqual
******************************************************************************/
static HRESULT WINAPI ItemMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
{
CLSID clsid;
LPOLESTR dispName1,dispName2;
IBindCtx* bind;
HRESULT res = S_FALSE;
TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
if (!pmkOtherMoniker) return S_FALSE;
/* check if both are ItemMoniker */
if(FAILED (IMoniker_GetClassID(pmkOtherMoniker,&clsid))) return S_FALSE;
if(!IsEqualCLSID(&clsid,&CLSID_ItemMoniker)) return S_FALSE;
/* check if both displaynames are the same */
if(SUCCEEDED ((res = CreateBindCtx(0,&bind)))) {
if(SUCCEEDED (IMoniker_GetDisplayName(iface,bind,NULL,&dispName1))) {
if(SUCCEEDED (IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&dispName2))) {
if(lstrcmpW(dispName1,dispName2)==0) res = S_OK;
CoTaskMemFree(dispName2);
}
CoTaskMemFree(dispName1);
}
}
return res;
}
示例5: CreateURLMoniker
void CMFCBindCntrItem::LoadFromMoniker(LPUNKNOWN pUnk, OLECHAR* szwName)
{
HRESULT hr;
// Ask the system for a URL Moniker
IMoniker* pIMoniker;
hr = CreateURLMoniker(NULL, (LPWSTR)szwName, &pIMoniker);
if ( SUCCEEDED(hr) )
{
// Get the IPersistMoniker interface
IPersistMoniker* pPMk;
hr = pUnk->QueryInterface(
IID_IPersistMoniker,
(void **)&pPMk);
if ( SUCCEEDED(hr) )
{
// note: do not register our BSC when calling IPM::Load directly
IBindCtx *pBCtx;
hr = CreateBindCtx(0, &pBCtx);
if ( SUCCEEDED(hr) )
{
// Call Load on the IPersistMoniker
hr = pPMk->Load(FALSE, pIMoniker, pBCtx, STGM_READ);
pBCtx->Release();
}
pPMk->Release();
}
pIMoniker->Release( );
}
}
示例6: bindObject
/* Newer COM libraries supply the functionality of
bindObject() via CoGetObject(), but to avoid depending
on that being around, we stick with our own implementation.
*/
HRESULT bindObject( const WCHAR* name, IID* iid, void** unk )
{
HRESULT hr;
IBindCtx *bc;
IMoniker *mk;
ULONG count;
if (!unk) return E_POINTER;
else *unk = NULL;
if (!iid) return E_POINTER;
bc = NULL;
mk = NULL;
hr = CreateBindCtx(0, &bc);
if (FAILED(hr)) return hr;
hr = MkParseDisplayName(bc, name, &count, &mk);
if (FAILED(hr)) { IUnknown_Release(bc); return hr; }
hr = IMoniker_BindToObject( mk, bc, NULL, iid, unk );
IUnknown_Release(mk);
IUnknown_Release(bc);
return hr;
}
示例7: HlinkResolveMonikerForData
/***********************************************************************
* HlinkResolveMonikerForData ([email protected])
*/
HRESULT WINAPI HlinkResolveMonikerForData(LPMONIKER pimkReference, DWORD reserved, LPBC pibc,
ULONG cFmtetc, FORMATETC *rgFmtetc, IBindStatusCallback *pibsc, LPMONIKER pimkBase)
{
LPOLESTR name = NULL;
IBindCtx *bctx;
DWORD mksys = 0;
void *obj = NULL;
HRESULT hres;
TRACE("(%p %x %p %d %p %p %p)\n", pimkReference, reserved, pibc, cFmtetc, rgFmtetc, pibsc, pimkBase);
if(cFmtetc || rgFmtetc || pimkBase)
FIXME("Unsupported args\n");
hres = RegisterBindStatusCallback(pibc, pibsc, NULL /* FIXME */, 0);
if(FAILED(hres))
return hres;
hres = IMoniker_IsSystemMoniker(pimkReference, &mksys);
if(SUCCEEDED(hres) && mksys != MKSYS_URLMONIKER)
WARN("sysmk = %x\n", mksys);
/* FIXME: What is it for? */
CreateBindCtx(0, &bctx);
hres = IMoniker_GetDisplayName(pimkReference, bctx, NULL, &name);
IBindCtx_Release(bctx);
if(SUCCEEDED(hres)) {
TRACE("got display name %s\n", debugstr_w(name));
CoTaskMemFree(name);
}
return IMoniker_BindToStorage(pimkReference, pibc, NULL, &IID_IUnknown, &obj);
}
示例8: StgOpenStorageEx
int BookServerTest::readFileMoniker()
{
ComPtr<IStorage> pStorage;
ComPtr<IStream> pStream;
auto hr = StgOpenStorageEx(kMonikerFileName,
STGM_READ | STGM_SHARE_EXCLUSIVE | STGM_DIRECT, STGFMT_STORAGE, 0, NULL, 0, IID_IStorage, (void**)&pStorage);
if (FAILED(hr))
return hr;
hr = pStorage->OpenStream(kStreamName, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream);
if (FAILED(hr))
return hr;
ComPtr<IMoniker> moniker;
OleLoadFromStream(pStream, IID_IMoniker, (void**)&moniker);
IBindCtx* pbc;
CreateBindCtx(0, &pbc);
ComPtr<IBook> book;
hr = moniker->BindToObject(pbc, NULL, IID_IBook, (void**)&book);
if (FAILED(hr)) {
return -1;
}
ComBSTR name;
book->get_name(&name);
assert(name == kBookName);
return 0;
}
示例9: IHlink_fnNavigate
static HRESULT WINAPI IHlink_fnNavigate(IHlink* iface, DWORD grfHLNF, LPBC pbc,
IBindStatusCallback *pbsc, IHlinkBrowseContext *phbc)
{
HlinkImpl *This = impl_from_IHlink(iface);
IMoniker *mon = NULL;
HRESULT r;
FIXME("Semi-Stub:(%p)->(%i %p %p %p)\n", This, grfHLNF, pbc, pbsc, phbc);
r = __GetMoniker(This, &mon, HLINKGETREF_ABSOLUTE);
TRACE("Moniker %p\n", mon);
if (SUCCEEDED(r))
{
IBindCtx *bcxt;
IUnknown *unk = NULL;
IHlinkTarget *target;
CreateBindCtx(0, &bcxt);
RegisterBindStatusCallback(bcxt, pbsc, NULL, 0);
r = IMoniker_BindToObject(mon, bcxt, NULL, &IID_IUnknown, (void**)&unk);
if (r == S_OK)
{
r = IUnknown_QueryInterface(unk, &IID_IHlinkTarget, (void**)&target);
IUnknown_Release(unk);
}
if (r == S_OK)
{
IHlinkTarget_SetBrowseContext(target, phbc);
r = IHlinkTarget_Navigate(target, grfHLNF, This->Location);
IHlinkTarget_Release(target);
}
else
{
static const WCHAR szOpen[] = {'o','p','e','n',0};
LPWSTR target = NULL;
r = IHlink_GetStringReference(iface, HLINKGETREF_DEFAULT, &target, NULL);
if (SUCCEEDED(r) && target)
{
ShellExecuteW(NULL, szOpen, target, NULL, NULL, SW_SHOW);
CoTaskMemFree(target);
}
}
RevokeBindStatusCallback(bcxt, pbsc);
IBindCtx_Release(bcxt);
IMoniker_Release(mon);
}
if (This->Site)
IHlinkSite_OnNavigationComplete(This->Site, This->SiteData, 0, r, NULL);
TRACE("Finished Navigation\n");
return r;
}
示例10: getDevFilter
// Used (by getDeviceModes) to select a device
// so we can list its properties
static IBaseFilter* getDevFilter(QString devName)
{
IBaseFilter* devFilter = nullptr;
devName = devName.mid(6); // Remove the "video="
IMoniker* m = nullptr;
ICreateDevEnum* devenum = nullptr;
if (CoCreateInstance(CLSID_SystemDeviceEnum, nullptr, CLSCTX_INPROC_SERVER,
IID_ICreateDevEnum, (void**) &devenum) != S_OK)
return devFilter;
IEnumMoniker* classenum = nullptr;
if (devenum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,
(IEnumMoniker**)&classenum, 0) != S_OK)
return devFilter;
while (classenum->Next(1, &m, nullptr) == S_OK)
{
LPMALLOC coMalloc = nullptr;
IBindCtx* bindCtx = nullptr;
LPOLESTR olestr = nullptr;
char* devIdString;
if (CoGetMalloc(1, &coMalloc) != S_OK)
goto fail;
if (CreateBindCtx(0, &bindCtx) != S_OK)
goto fail;
if (m->GetDisplayName(bindCtx, nullptr, &olestr) != S_OK)
goto fail;
devIdString = wcharToUtf8(olestr);
// replace ':' with '_' since FFmpeg uses : to delimitate sources
for (unsigned i = 0; i < strlen(devIdString); i++)
if (devIdString[i] == ':')
devIdString[i] = '_';
if (devName != devIdString)
goto fail;
if (m->BindToObject(0, 0, IID_IBaseFilter, (void**)&devFilter) != S_OK)
goto fail;
fail:
if (olestr && coMalloc)
coMalloc->Free(olestr);
if (bindCtx)
bindCtx->Release();
delete[] devIdString;
m->Release();
}
classenum->Release();
if (!devFilter)
qWarning() << "Could't find the device "<<devName;
return devFilter;
}
示例11: AccessVisualStudio
/** Accesses the correct visual studio instance if possible. */
bool AccessVisualStudio(CComPtr<EnvDTE::_DTE>& OutDTE, const FString& InSolutionPath, const TArray<FVSAccessorModule::VisualStudioLocation>& InLocations)
{
bool bSuccess = false;
// Open the Running Object Table (ROT)
IRunningObjectTable* RunningObjectTable;
if (SUCCEEDED(GetRunningObjectTable(0, &RunningObjectTable)) &&
RunningObjectTable)
{
IEnumMoniker* MonikersTable;
RunningObjectTable->EnumRunning(&MonikersTable);
MonikersTable->Reset();
// Look for all visual studio instances in the ROT
IMoniker* CurrentMoniker;
while (!bSuccess && MonikersTable->Next(1, &CurrentMoniker, NULL) == S_OK)
{
IBindCtx* BindContext;
LPOLESTR OutName;
CComPtr<IUnknown> ComObject;
if (SUCCEEDED(CreateBindCtx(0, &BindContext)) &&
SUCCEEDED(CurrentMoniker->GetDisplayName(BindContext, NULL, &OutName)) &&
IsVisualStudioMoniker(FString(OutName), InLocations) &&
SUCCEEDED(RunningObjectTable->GetObject(CurrentMoniker, &ComObject)))
{
CComPtr<EnvDTE::_DTE> TempDTE;
TempDTE = ComObject;
// Get the solution path for this instance
// If it equals the solution we would have opened above in RunVisualStudio(), we'll take that
CComPtr<EnvDTE::_Solution> Solution;
LPOLESTR OutPath;
if (SUCCEEDED(TempDTE->get_Solution(&Solution)) &&
SUCCEEDED(Solution->get_FullName(&OutPath)))
{
FString Filename(OutPath);
FPaths::NormalizeFilename(Filename);
if( Filename == InSolutionPath )
{
OutDTE = TempDTE;
bSuccess = true;
}
}
}
BindContext->Release();
CurrentMoniker->Release();
}
MonikersTable->Release();
RunningObjectTable->Release();
}
return bSuccess;
}
示例12: EnumRunningObjectTable
static NTSTATUS EnumRunningObjectTable(
_In_ PVOID ThreadParam
)
{
IRunningObjectTable* iRunningObjectTable = NULL;
IEnumMoniker* iEnumMoniker = NULL;
IMoniker* iMoniker = NULL;
IBindCtx* iBindCtx = NULL;
IMalloc* iMalloc = NULL;
ULONG count = 0;
HWND listViewHandle = (HWND)ThreadParam;
if (!SUCCEEDED(CoGetMalloc(1, &iMalloc)))
return STATUS_INSUFFICIENT_RESOURCES;
// Query the running object table address
if (SUCCEEDED(GetRunningObjectTable(0, &iRunningObjectTable)))
{
// Enum the objects registered
if (SUCCEEDED(IRunningObjectTable_EnumRunning(iRunningObjectTable, &iEnumMoniker)))
{
while (IEnumMoniker_Next(iEnumMoniker, 1, &iMoniker, &count) == S_OK)
{
if (SUCCEEDED(CreateBindCtx(0, &iBindCtx)))
{
OLECHAR* displayName = NULL;
// Query the object name
if (SUCCEEDED(IMoniker_GetDisplayName(iMoniker, iBindCtx, NULL, &displayName)))
{
// Set the items name column
PhAddListViewItem(listViewHandle, MAXINT, displayName, NULL);
// Free the object name
IMalloc_Free(iMalloc, displayName);
}
IBindCtx_Release(iBindCtx);
}
IEnumMoniker_Release(iMoniker);
}
IEnumMoniker_Release(iEnumMoniker);
}
IRunningObjectTable_Release(iRunningObjectTable);
}
IMalloc_Release(iMalloc);
return STATUS_SUCCESS;
}
示例13: FindInterpreterObject
static int
FindInterpreterObject(
Tcl_Interp *interp,
const char *name,
LPDISPATCH *ppdisp)
{
LPRUNNINGOBJECTTABLE pROT = NULL;
int result = TCL_OK;
HRESULT hr = GetRunningObjectTable(0, &pROT);
if (SUCCEEDED(hr)) {
IBindCtx* pBindCtx = NULL;
hr = CreateBindCtx(0, &pBindCtx);
if (SUCCEEDED(hr)) {
LPMONIKER pmk = NULL;
hr = BuildMoniker(name, &pmk);
if (SUCCEEDED(hr)) {
IUnknown *pUnkInterp = NULL, **ppUnkInterp = &pUnkInterp;
hr = pROT->lpVtbl->IsRunning(pROT, pmk);
hr = pmk->lpVtbl->BindToObject(pmk, pBindCtx, NULL,
&IID_IUnknown, (void **) ppUnkInterp);
if (SUCCEEDED(hr)) {
hr = pUnkInterp->lpVtbl->QueryInterface(pUnkInterp,
&IID_IDispatch, (void **) ppdisp);
pUnkInterp->lpVtbl->Release(pUnkInterp);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"no application named \"%s\"", name));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "APPLICATION",
NULL);
result = TCL_ERROR;
}
pmk->lpVtbl->Release(pmk);
}
pBindCtx->lpVtbl->Release(pBindCtx);
}
pROT->lpVtbl->Release(pROT);
}
if (FAILED(hr) && result == TCL_OK) {
Tcl_SetObjResult(interp, Win32ErrorObj(hr));
result = TCL_ERROR;
}
return result;
}
示例14: TCTrace
STDMETHODIMP CTCBindHost::MonikerBindToStorage( IMoniker* pMoniker,
IBindCtx* pBindCtx, IBindStatusCallback* pBSC, REFIID iid, void** ppObject )
{
HRESULT hResult;
IBindCtxPtr pNewBindCtx;
TCTrace( TRACELEVEL_NORMAL, "IBindHost::MonikerBindToStorage\n" );
if( ppObject == NULL )
{
return( E_POINTER );
}
*ppObject = NULL;
if( pBindCtx != NULL )
{
pNewBindCtx = pBindCtx;
if( pBSC )
{
hResult = RegisterBindStatusCallback( pBindCtx, pBSC, NULL, 0 );
if( FAILED( hResult ) )
{
return( hResult );
}
}
}
else
{
if( pBSC )
{
hResult = CreateAsyncBindCtx( 0, pBSC, NULL, &pNewBindCtx );
if( FAILED( hResult ) )
{
return( hResult );
}
}
else
{
hResult = CreateBindCtx( 0, &pNewBindCtx );
if( FAILED( hResult ) )
{
return( hResult );
}
}
}
ASSERT( pNewBindCtx != NULL );
return( pMoniker->BindToStorage( pNewBindCtx, NULL, iid, ppObject ) );
}
示例15: QAudioOutputSelectorControl
DirectShowAudioEndpointControl::DirectShowAudioEndpointControl(
DirectShowPlayerService *service, QObject *parent)
: QAudioOutputSelectorControl(parent)
, m_service(service)
, m_bindContext(0)
, m_deviceEnumerator(0)
{
if (CreateBindCtx(0, &m_bindContext) == S_OK) {
m_deviceEnumerator = com_new<ICreateDevEnum>(CLSID_SystemDeviceEnum, IID_ICreateDevEnum);
updateEndpoints();
setActiveOutput(m_defaultEndpoint);
}
}