示例#1
0
void WINAPI duFlash::OnCreate()
{
	IUnknown *pControl = NULL;
	IUnknown *pContainer = NULL;
	HRESULT hr = CreateAxControl(this->GetHwnd(), L"ShockwaveFlash.ShockwaveFlash", &pControl, &pContainer);
	if (FAILED(hr))
		return;
	
	AxAdviseAll(this, pControl);
	
	hr = pControl->QueryInterface(__uuidof(IShockwaveFlash), (void **)&m_pFlash);
	hr = m_pFlash->put_Movie(m_szURL);
	hr = m_pFlash->put_AllowFullScreen(L"true");
	
	IOleWindow *pOleWindow = NULL;
	hr = pControl->QueryInterface(IID_IOleWindow, (void **)&pOleWindow);
				
	HWND hWndObject = NULL;
	pOleWindow->GetWindow(&hWndObject);
	pOleWindow->Release();
	
	Attach(hWndObject);

	m_pContainer = pContainer;
	m_pContainer->AddRef();

	pControl->Release();
	pContainer->Release();
}
示例#2
0
// @pymethod |PyIDocHostUIHandler|ShowContextMenu|Description of ShowContextMenu.
PyObject *PyIDocHostUIHandler::ShowContextMenu(PyObject *self, PyObject *args)
{
	IDocHostUIHandler *pIDHUIH = GetI(self);
	if ( pIDHUIH == NULL )
		return NULL;
	// @pyparm int|dwID||Description for dwID
	POINT pt;
	// @pyparm (int, int)|pt||Description for ppt
	// @pyparm <o PyIUnknown>|pcmdtReserved||Description for pcmdtReserved
	// @pyparm <o PyIDispatch>|pdispReserved||Description for pdispReserved
	PyObject *obpcmdtReserved;
	PyObject *obpdispReserved;
	DWORD dwID;
	IUnknown * pcmdtReserved;
	IDispatch * pdispReserved;
	if ( !PyArg_ParseTuple(args, "l(ii)OO:ShowContextMenu", &dwID, &pt.x, &pt.y,
			       &obpcmdtReserved, &obpdispReserved) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obpcmdtReserved, IID_IUnknown, (void **)&pcmdtReserved, TRUE /* bNoneOK */))
		return NULL;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obpdispReserved, IID_IDispatch, (void **)&pdispReserved, TRUE /* bNoneOK */)) {
		if (pcmdtReserved) pcmdtReserved->Release();
		return NULL;
	}
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIDHUIH->ShowContextMenu( dwID, &pt, pcmdtReserved, pdispReserved );
	if (pcmdtReserved) pcmdtReserved->Release();
	if (pdispReserved) pdispReserved->Release();
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIDHUIH, IID_IDocHostUIHandler );
	return PyInt_FromLong(hr);
}
示例#3
0
BOOL IsExcelThere()
{
    IRunningObjectTable *pRot = NULL;
    ::GetRunningObjectTable(0, &pRot);

    IEnumMoniker *pEnum = NULL;
    pRot->EnumRunning(&pEnum);
    IMoniker* pMon[1] = { NULL };
    ULONG fetched = 0;
    BOOL found = FALSE;
    while (pEnum->Next(1, pMon, &fetched) == 0)
    {
        IUnknown *pUnknown;
        pRot->GetObject(pMon[0], &pUnknown);
        IUnknown *pWorkbook;
        if (SUCCEEDED(pUnknown->QueryInterface(DIID__Workbook, (void **) &pWorkbook)))
        {
            found = TRUE;
            pWorkbook->Release();
            break;
        }
        pUnknown->Release();
    }

    if (pRot != NULL)
        pRot->Release();

    if (pEnum != NULL)
        pEnum->Release();

    return found;
}
示例#4
0
void CHTMLViewCapView::DocumentComplete(LPDISPATCH pDisp, VARIANT* URL)
{
	UNUSED_ALWAYS(pDisp);
	UNUSED_ALWAYS(URL);

	HRESULT hr;
	IUnknown* pUnkBrowser = NULL;
    IUnknown* pUnkDisp = NULL;

	// 这个 DocumentComplete 事件是否是顶层框架窗口的?
    // 检查 COM 标识: 比较IUnknown 接口指针.
	hr = m_pBrowserApp->QueryInterface(IID_IUnknown, (void**)&pUnkBrowser);

	if ( SUCCEEDED(hr) ) {
		hr = pDisp->QueryInterface(IID_IUnknown,  (void**)&pUnkDisp);

		if ( SUCCEEDED(hr) ) {
			if ( pUnkBrowser == pUnkDisp ) {
				TRACE("Top Document completely loaded!\n");
				EndModalLoop(S_OK);
				//::SetEvent(m_hDocCompleteEvent);
			}
		}

		pUnkDisp->Release();
	}
	pUnkBrowser->Release();
}
///////////////////////////////////////////////////////////////////
// SameCall
//
// check if same call object as g_pCall
//
///////////////////////////////////////////////////////////////////
bool SameCall(ITCallStateEvent* pCallStateEvent)
{

	//
	// sanity check
	//
	if(NULL == pCallStateEvent)
	{
		return false;
	}

	//
	//get call object
	//
	ITCallInfo* pCallInfo = NULL;
	HRESULT hr = pCallStateEvent->get_Call(&pCallInfo);
	//
	//check if we have a call and get_Call succeded
	//
	if(NULL != pCallInfo &&  ( SUCCEEDED(hr) && NULL != g_pCall) )
	{
		bool bIsEqual = true;
		//
		//get and compare IUnknown for both objects
		//
		IUnknown* pIUnkCallInfo = NULL;
		IUnknown* pIUnkCallControl = NULL;
		pCallInfo->QueryInterface(IID_IUnknown, (void**)&pIUnkCallInfo);
		g_pCall->QueryInterface(IID_IUnknown, (void**)&pIUnkCallControl);
		//
		//compare
		//
		if(pIUnkCallInfo != pIUnkCallControl)
		{
			bIsEqual = false;
		}

		//
		//clean up
		//
		pCallInfo->Release();
		if(NULL != pIUnkCallInfo)
		{
			pIUnkCallInfo->Release();
		}
		if(NULL != pIUnkCallControl)
		{
			pIUnkCallControl->Release();
		}
		return bIsEqual;
	}
	else
	{
		return false;
	}

}
STDMETHODIMP FWmfMediaByteStream::Invoke(IMFAsyncResult* AsyncResult)
{
	// recover read state
	IUnknown* State = NULL;
	
	if (FAILED(AsyncResult->GetState(&State)))
	{
		return S_OK;
	}

	IMFAsyncResult* CallerResult = NULL;

	if (FAILED(State->QueryInterface(IID_PPV_ARGS(&CallerResult))))
	{
		return S_OK;
	}

	IUnknown* Unknown = NULL;
	
	if ((CallerResult != NULL) && FAILED(CallerResult->GetObject(&Unknown)))
	{
		return S_OK;
	}

	FWmfMediaReadState* ReadState = static_cast<FWmfMediaReadState*>(Unknown);

	// perform the read
	ULONG cbRead;
	Read(ReadState->GetReadBuffer(), ReadState->GetReadBufferSize() - ReadState->GetBytesRead(), &cbRead);
	ReadState->AddBytesRead(cbRead);

	// notify caller
	if (CallerResult != NULL)
	{
		CallerResult->SetStatus(S_OK);
		::MFInvokeCallback(CallerResult);
	}

	// clean up
	if (CallerResult != NULL)
	{
		CallerResult->Release();
	}

	if (Unknown != NULL)
	{
		Unknown->Release();
	}

	if (State != NULL)
	{
		State->Release();
	}

	return S_OK;
}
示例#7
0
//---------------------------------------------------------------------------
bool __fastcall TTSSWaveContext::Start(AnsiString filename)
{
	if(FDecoder) FDecoder->Release(), FDecoder = NULL;


	HRESULT hr;
	IUnknown * decoder;

	hr = FModule->GetMediaInstance(WideString(filename).c_bstr(), &decoder);
	if(FAILED(hr))
	{
		throw Exception(filename + " は開くことができません");
	}

	hr = decoder->QueryInterface(IID_ITSSWaveDecoder, (void**)&FDecoder);
	if(FAILED(hr))
	{
		decoder->Release();
		FDecoder = NULL;
		throw Exception(filename + " のメディア・タイプは扱うことができません");
	}

	decoder->Release();

	TSSWaveFormat format;
	FDecoder->GetFormat(&format);
	if(format.dwBitsPerSample != 16)
	{
		throw Exception(filename + " は 16bit PCM に変換できないため扱うことができません");
	}
	if(format.dwChannels > 8)
	{
		throw Exception(filename + " は 9チャネル以上あるため扱うことができません");
	}
	if(format.ui64TotalSamples == 0)
	{
		throw Exception(filename + " は 総サンプル数が不明か、ゼロのため扱うことができません");
	}
	if(format.ui64TotalSamples >= 0x10000000ui64)
	{
		throw Exception(filename + " は 大きすぎるため、扱うことができません");
	}
	FChannels = format.dwChannels;
	FFrequency = format.dwSamplesPerSec;
	FBitsPerSample = 16;
	FSpeakerConfig = 0; // 現時点では常に 0 (なにか規格をつくるかも)
	FTotalSamples = (int)format.ui64TotalSamples;

	FGranuleSize = FChannels * sizeof(__int16);

//	FDecoder->SetPosition(0); /// test

	return true;
}
示例#8
0
HRESULT STDMETHODCALLTYPE CHtmlViewer::WebBrowserEventCallBack(DISPID dispidMember,
                                                  REFIID riid,
                                                  LCID lcid,
                                                  WORD wFlags,
                                                  DISPPARAMS* pdispparams,
                                                  VARIANT* pvarResult,
                                                  EXCEPINFO* pexcepinfo,
                                                  UINT* puArgErr)
{
    UNREFERENCED_PARAMETER(puArgErr);
    UNREFERENCED_PARAMETER(pexcepinfo);
    UNREFERENCED_PARAMETER(pvarResult);
    UNREFERENCED_PARAMETER(riid);
    UNREFERENCED_PARAMETER(lcid);
    UNREFERENCED_PARAMETER(wFlags);
    UNREFERENCED_PARAMETER(pdispparams);

    switch (dispidMember)
    {
    case DISPID_DOCUMENTCOMPLETE:
        {
        this->OnDocumentCompleted();
        // pdispparams->rgvarg[0] : url
        // pdispparams->rgvarg[1]

        LPDISPATCH pDisp=pdispparams->rgvarg[1].pdispVal;
        HRESULT hr;
        IUnknown* pUnkBrowser = NULL;
        IUnknown* pUnkDisp = NULL;

        hr = this->pIWebBrowser->QueryInterface( IID_IUnknown,  (void**)&pUnkBrowser );
        if ( SUCCEEDED(hr) )
        {
            hr = pDisp->QueryInterface( IID_IUnknown,  (void**)&pUnkDisp );
            if ( SUCCEEDED(hr) )
            {
                if ( pUnkBrowser == pUnkDisp )
                {   // This is the DocumentComplete event for the top frame - page is loaded!
                    SetEvent(this->hEvtDocumentFullyCompleted);
                }
                pUnkDisp->Release();
            }
            pUnkBrowser->Release();
        }
        }
        break;
    case DISPID_NAVIGATEERROR:
        SetEvent(this->hEvtNavigateError);
        break;
    }
    return S_OK;
}
示例#9
0
static HRESULT STDMETHODCALLTYPE hook_present(IDXGISwapChain *swap,
        UINT sync_interval, UINT flags)
{
    IUnknown *backbuffer = nullptr;
    bool capture_overlay = global_hook_info->capture_overlay;
    bool test_draw = (flags & DXGI_PRESENT_TEST) != 0;
    bool capture;
    HRESULT hr;

    if (!data.swap && !capture_active()) {
        setup_dxgi(swap);
    }

    capture = !test_draw && swap == data.swap && !!data.capture;
    if (capture && !capture_overlay) {
        backbuffer = get_dxgi_backbuffer(swap);

        if (!!backbuffer) {
            data.capture(swap, backbuffer, capture_overlay);
            backbuffer->Release();
        }
    }

    unhook(&present);
    present_t call = (present_t)present.call_addr;
    hr = call(swap, sync_interval, flags);
    rehook(&present);

    if (capture && capture_overlay) {
        /*
         * It seems that the first call to Present after ResizeBuffers
         * will cause the backbuffer to be invalidated, so do not
         * perform the post-overlay capture if ResizeBuffers has
         * recently been called.  (The backbuffer returned by
         * get_dxgi_backbuffer *will* be invalid otherwise)
         */
        if (resize_buffers_called) {
            resize_buffers_called = false;
        } else {
            backbuffer = get_dxgi_backbuffer(swap);

            if (!!backbuffer) {
                data.capture(swap, backbuffer, capture_overlay);
                backbuffer->Release();
            }
        }
    }

    return hr;
}
示例#10
0
static bool setup_dxgi(IDXGISwapChain *swap)
{
    const char *process_name = get_process_name();
    bool ignore_d3d10 = false;
    IUnknown *device;
    HRESULT hr;

    /* Call of duty ghosts allows the context to be queried as a d3d10
     * context when it's actually a d3d11 context.  Why this is I don't
     * quite know. */
    if (_strcmpi(process_name, "iw6sp64_ship.exe") == 0 ||
            _strcmpi(process_name, "iw6mp64_ship.exe") == 0 ||
            _strcmpi(process_name, "justcause3.exe") == 0) {
        ignore_d3d10 = true;
    }

    if (!ignore_d3d10) {
        hr = swap->GetDevice(__uuidof(ID3D10Device), (void**)&device);
        if (SUCCEEDED(hr)) {
            data.swap = swap;
            data.capture = d3d10_capture;
            data.free = d3d10_free;
            device->Release();
            return true;
        }
    }

    hr = swap->GetDevice(__uuidof(ID3D11Device), (void**)&device);
    if (SUCCEEDED(hr)) {
        data.swap = swap;
        data.capture = d3d11_capture;
        data.free = d3d11_free;
        device->Release();
        return true;
    }

#if COMPILE_D3D12_HOOK
    hr = swap->GetDevice(__uuidof(ID3D12Device), (void**)&device);
    if (SUCCEEDED(hr)) {
        data.swap = swap;
        data.capture = d3d12_capture;
        data.free = d3d12_free;
        device->Release();
        return true;
    }
#endif

    return false;
}
示例#11
0
文件: com4j.cpp 项目: Alcar32/com4j
JNIEXPORT jlong JNICALL Java_com4j_Native_createInstance(
	JNIEnv* env, jclass __unused__, jstring _progId, jint clsctx, jlong iid1, jlong iid2 ) {
	
	MyGUID iid(iid1,iid2);
	CLSID clsid;
	HRESULT hr;
	JString progId(env,_progId);

	hr = CLSIDFromProgID(progId,&clsid);
	if(FAILED(hr)) {
		if(FAILED(CLSIDFromString( const_cast<LPOLESTR>(LPCOLESTR(progId)),&clsid))) {
			error(env,__FILE__,__LINE__,hr,"Unrecognized CLSID");
			return 0;
		}
	}

	void* p;

	if(clsctx&(CLSCTX_LOCAL_SERVER|CLSCTX_REMOTE_SERVER)) {
		IUnknown* pUnk = NULL;
		hr = CoCreateInstance(clsid,NULL,clsctx,__uuidof(IUnknown),(void**)&pUnk);
		if(FAILED(hr)) {
			error(env,__FILE__,__LINE__,hr,"CoCreateInstance failed");
			return 0;
		}
		hr = OleRun(pUnk);
		if(FAILED(hr)) {
			pUnk->Release();
			error(env,__FILE__,__LINE__,hr,"OleRun failed");
			return 0;
		}
		hr = pUnk->QueryInterface(iid,&p);
		pUnk->Release();

		if(FAILED(hr)) {
			error(env,__FILE__,__LINE__,hr,"QueryInterface failed");
			return 0;
		}

	} else {
		// just the plain CoCreateInstance
		hr = CoCreateInstance(clsid,NULL,clsctx,iid,&p);
		if(FAILED(hr)) {
			error(env,__FILE__,__LINE__,hr,"CoCreateInstance failed");
			return 0;
		}
	}
	return reinterpret_cast<jlong>(p);
}
示例#12
0
STDMETHODIMP CDlrComServer::GetObjArray(SAFEARRAY **ppsaRetVal)
{
    CComSafeArray<LPUNKNOWN>      csaData;
    void HUGEP              *pvData = NULL;
    IUnknown*                     punkThis = NULL;
    IUnknown*                     punkOther = NULL;
    void* rgData[] = { 0, 0 };
    HRESULT hr = S_OK;

    hr = csaData.Create(2, 0);
    if (FAILED(hr)) 
        goto Error;

    hr = SafeArrayAccessData((LPSAFEARRAY)csaData, (void HUGEP **)&pvData);
    if (FAILED(hr))
        goto Error;

    hr = this->QueryInterface(IID_IUnknown, (void**)&punkThis);
    if (FAILED(hr))
        goto Error;

    hr = CoCreateInstance(CLSID_DlrComServer, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void**)&punkOther);
    if (FAILED(hr))
        goto Error;

    rgData[0] = punkThis;
    rgData[1] = punkOther;

    memcpy((void*)pvData, rgData, sizeof(rgData));

    hr = SafeArrayUnaccessData((LPSAFEARRAY)csaData);
    if (FAILED(hr))
        goto Error;

    punkThis = 0;
    punkOther = 0;

    *ppsaRetVal = csaData.Detach();

Error:
    if (punkThis)
        punkThis->Release();

    if (punkOther)
        punkOther->Release();

    return hr;
}
// Ordinarily we would look at the CPUS and decide whether or not we support this scenario.
// However, in this scenario we're going to create our internal provider and let it answer
// questions like this for us.
HRESULT CTotpProvider::SetUsageScenario(
    __in CREDENTIAL_PROVIDER_USAGE_SCENARIO cpus,
    __in DWORD dwFlags
    )
{
    HRESULT hr;

    // Create the password credential provider and query its interface for an
    // ICredentialProvider we can use. Once it's up and running, ask it about the 
    // usage scenario being provided.
    IUnknown *pUnknown = NULL;
	hr = CoCreateInstance(CLSID_V1PasswordCredentialProvider, NULL, CLSCTX_ALL, IID_PPV_ARGS(&pUnknown));
    if (SUCCEEDED(hr))
    {
        hr = pUnknown->QueryInterface(IID_PPV_ARGS(&(_pWrappedProvider)));
        if (SUCCEEDED(hr))
        {
            hr = _pWrappedProvider->SetUsageScenario(cpus, dwFlags);
        }
        pUnknown->Release();
    }
    if (FAILED(hr))
    {
        if (_pWrappedProvider != NULL)
        {
            _pWrappedProvider->Release();
            _pWrappedProvider = NULL;
        }
    }

    return hr;
}
示例#14
0
HRESULT GetInstalledClrRuntimes(ICLRMetaHost *clrMetaHost, std::vector<std::wstring>& clrRuntimeList)
{
    HRESULT hr = S_OK;		
    clrRuntimeList.clear();

    IEnumUnknown* runtimeEnumerator = nullptr;
    hr = clrMetaHost->EnumerateInstalledRuntimes(&runtimeEnumerator);
    if (SUCCEEDED(hr)) {
        WCHAR currentRuntime[50];
        DWORD bufferSize = ARRAYSIZE(currentRuntime);
        IUnknown* runtime = nullptr;
        while (runtimeEnumerator->Next(1, &runtime, NULL) == S_OK)
        {
            ICLRRuntimeInfo* runtimeInfo = nullptr;
            hr = runtime->QueryInterface(IID_PPV_ARGS(&runtimeInfo));
            if (SUCCEEDED(hr))
            {
                hr = runtimeInfo->GetVersionString(currentRuntime, &bufferSize);
                if (SUCCEEDED(hr))
                {
                    clrRuntimeList.push_back(std::wstring(currentRuntime));
                }
                runtimeInfo->Release();
            }
            runtime->Release();
        }
        runtimeEnumerator->Release();
        hr = S_OK;
    }

    return hr;
}
// @pymethod |PyIDebugApplication|FireDebuggerEvent|Fire a generic event to the IApplicationDebugger (if any)
PyObject *PyIDebugApplication::FireDebuggerEvent(PyObject *self, PyObject *args)
{
	PY_INTERFACE_METHOD;
	IDebugApplication *pIDA = GetI(self);
	if ( pIDA == NULL )
		return NULL;
	// @pyparm <o PyIIID>|guid||A GUID.
	// @pyparm <o PyIUnknown>|unknown||An unknown object.
	PyObject *obguid, *obunk;
	if ( !PyArg_ParseTuple(args, "OO:FireDebuggerEvent", &obguid, &obunk) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	IUnknown *punk;
	IID iid;
	if (!PyWinObject_AsIID(obguid, &iid))
		 bPythonIsHappy = FALSE;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obunk, IID_IUnknown, (void **)&punk, FALSE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIDA->FireDebuggerEvent( iid, punk );
	punk->Release();
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return SetPythonCOMError(self,hr);
	Py_INCREF(Py_None);
	return Py_None;
}
示例#16
0
/*
BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}

*/
HRESULT GetNotificationFactory(
    HANDLE notificationEventHandle,
    IUnknown** ppProxyShimFactory
    )
{
    HRESULT hr = S_OK;
    IUnknown* pIDtcProxyShimFactory = NULL;
    NotificationShimFactory* factory = NULL;

    if ( NULL == ppProxyShimFactory )
    {
        return E_INVALIDARG;
    }


    // Create the NotificationShimFactory.
#pragma warning( push )
#pragma warning( disable : 4068 )
#pragma prefast(suppress:6014, "The memory is deallocated when the managed code RCW gets collected")
    factory = new NotificationShimFactory();
#pragma warning( pop )
    if ( NULL == factory )
    {
        hr = E_OUTOFMEMORY;
        goto Done;
    }

    hr = factory->Initialize( notificationEventHandle );
    if ( FAILED( hr ) )
    {
        goto Done;
    }

    hr = factory->QueryInterface( IID_IUnknown, (void**) &pIDtcProxyShimFactory );
    if ( FAILED( hr ) )
    {
        goto Done;
    }

    *ppProxyShimFactory = pIDtcProxyShimFactory;

Done:


    if ( S_OK != hr ) 
    {
        if ( NULL != pIDtcProxyShimFactory )
        {
            pIDtcProxyShimFactory->Release();
            factory = NULL;
        }

        if ( NULL != factory )
        {
            delete factory;
        }
    }

    return hr;
}
// @pymethod int|PyIConnectionPoint|Advise|Establishes a connection between the connection point object and the client's sink.
PyObject *PyIConnectionPoint::Advise(PyObject *self, PyObject *args)
{
	PyObject *obUnk;
	// @pyparm <o PyIUnknown>|unk||The client's advise sink
	if ( !PyArg_ParseTuple(args, "O:Advise", &obUnk) )
		return NULL;

	IUnknown *pUnk;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obUnk, IID_IUnknown, (void **)&pUnk, FALSE))
		return NULL;

	IConnectionPoint *pICP = GetI(self);
	if ( pICP == NULL )
		return NULL;

	DWORD cookie;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pICP->Advise( pUnk, &cookie );
	pUnk->Release();
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return SetPythonCOMError(self,hr);
	// @rdesc The result is the connection point identifier used by <om PyIConnectionPoint::Unadvise>
	return PyInt_FromLong(cookie);
}
ULONG   CProxyDirect3DDevice9::Release                        ( VOID )
{
    ULONG       ulResult;
    IUnknown *  pDestroyedDevice;

    // Check to see if we should destroy ourself
    if ( --m_dwRefCount == 0 )
    {
        WriteDebugEvent ( "Releasing IDirect3DDevice9 Proxy..." );

		// Call event handler
		CDirect3DEvents9::OnDirect3DDeviceDestroy ( m_pDevice );

        // Save device so we can destroy it after.
        pDestroyedDevice = m_pDevice;

        // Destroy...
        delete this;

		// Release device...
        ulResult = pDestroyedDevice->Release ( );

		return ulResult;
    }
	
	ulResult = m_pDevice->Release ( );

    return ulResult;
}
示例#19
0
//
// NonDelegatingQueryInterface
//
// This function is overwritten to expose IMediaPosition and IMediaSelection
// Note that only one output stream can be allowed to expose this to avoid
// conflicts, the other pins will just return E_NOINTERFACE and therefore
// appear as non seekable streams. We have a LONG value that if exchanged to
// produce a TRUE means that we have the honor. If it exchanges to FALSE then
// someone is already in. If we do get it and error occurs then we reset it
// to TRUE so someone else can get it.
//
STDMETHODIMP
CTeeOutputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv)
{
    CheckPointer(ppv,E_POINTER);
    ASSERT(ppv);

    *ppv = NULL;
    HRESULT hr = NOERROR;

    // See what interface the caller is interested in.
    if(riid == IID_IMediaPosition || riid == IID_IMediaSeeking)
    {
        if(m_pPosition)
        {
            if(m_bHoldsSeek == FALSE)
                return E_NOINTERFACE;
            return m_pPosition->QueryInterface(riid, ppv);
        }
    }
    else
    {
        return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);
    }

    CAutoLock lock_it(m_pLock);
    ASSERT(m_pPosition == NULL);
    IUnknown *pMediaPosition = NULL;

    // Try to create a seeking implementation
    if(InterlockedExchange(&m_pTee->m_lCanSeek, FALSE) == FALSE)
        return E_NOINTERFACE;

    // Create implementation of this dynamically as sometimes we may never
    // try and seek. The helper object implements IMediaPosition and also
    // the IMediaSelection control interface and simply takes the calls
    // normally from the downstream filter and passes them upstream

    hr = CreatePosPassThru(GetOwner(),
                           FALSE,
                           (IPin *)&m_pTee->m_Input,
                           &pMediaPosition);

    if(pMediaPosition == NULL)
    {
        InterlockedExchange(&m_pTee->m_lCanSeek, TRUE);
        return E_OUTOFMEMORY;
    }

    if(FAILED(hr))
    {
        InterlockedExchange(&m_pTee->m_lCanSeek, TRUE);
        pMediaPosition->Release();
        return hr;
    }

    m_pPosition = pMediaPosition;
    m_bHoldsSeek = TRUE;
    return NonDelegatingQueryInterface(riid, ppv);

} // NonDelegatingQueryInterface
STDMETHODIMP touchmind::control::DWriteEditControlTextStoreACP::AdviseSink(REFIID riid, IUnknown *pUnknown,
                                                                           DWORD dwMask) {
  HRESULT hr;
  IUnknown *punkID;

  hr = pUnknown->QueryInterface(IID_IUnknown, (LPVOID *)&punkID);
  if (FAILED(hr)) {
    return hr;
  }

  hr = E_INVALIDARG;

  if (punkID == m_AdviseSink.punkID) {
    m_AdviseSink.dwMask = dwMask;

    hr = S_OK;
  } else if (nullptr != m_AdviseSink.punkID) {
    hr = CONNECT_E_ADVISELIMIT;
  } else if (IsEqualIID(riid, IID_ITextStoreACPSink)) {
    m_AdviseSink.dwMask = dwMask;
    m_AdviseSink.punkID = punkID;

    punkID->AddRef();
    pUnknown->QueryInterface(IID_ITextStoreACPSink, (LPVOID *)&m_AdviseSink.pTextStoreACPSink);
    pUnknown->QueryInterface(IID_ITextStoreACPServices, (LPVOID *)&m_pServices);
    hr = S_OK;
  }

  punkID->Release();
  return hr;
}
示例#21
0
// @pymethod |PyIContext|SetProperty|Sets a property on the context
PyObject *PyIContext::SetProperty(PyObject *self, PyObject *args)
{
	IContext *pIC = GetI(self);
	if ( pIC == NULL )
		return NULL;
	// @pyparm <o PyIID>|rpolicyId||GUID identifying the property to be set
	// @pyparm int|flags||Reserved, use only 0
	// @pyparm <o PyIUnknown>|pUnk||The property value
	CPFLAGS flags;
	PyObject *obrpolicyId;
	PyObject *obUnk;
	IID rpolicyId;
	IUnknown * pUnk;
	if ( !PyArg_ParseTuple(args, "OkO:SetProperty", &obrpolicyId, &flags, &obUnk) )
		return NULL;
	if (!PyWinObject_AsIID(obrpolicyId, &rpolicyId))
		return NULL;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obUnk, IID_IUnknown, (void **)&pUnk, FALSE))
		return NULL;

	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIC->SetProperty( rpolicyId, flags, pUnk );
	pUnk->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIC, IID_IContext );
	Py_INCREF(Py_None);
	return Py_None;
}
/******************************Public*Routine******************************\
* SetFocus
*
\**************************************************************************/
void
CMovie::SetFocus()
{
    if(m_Fg)
    {
        // Tell the resource manager that we are being made active.  This
        // will then cause the sound to switch to us.  This is especially
        // important when playing audio only files as there is no other
        // playback window.
        IResourceManager* pResourceManager;

        HRESULT hr = m_Fg->QueryInterface(IID_IResourceManager, (void**)&pResourceManager);

        if(SUCCEEDED(hr))
        {
            IUnknown* pUnknown;

            hr = m_Fg->QueryInterface(IID_IUnknown, (void**)&pUnknown);

            if(SUCCEEDED(hr))
            {
                hr = pResourceManager->SetFocus(pUnknown);
                pUnknown->Release();
            }

            pResourceManager->Release();
        }
    }
}
示例#23
0
HRESULT CInProcPlugHole::StartVM(CLSCTX ctx)
{
	_ASSERTE(m_dwVMStarterId == 0);
	_ASSERTE(m_hDolphinThread == 0);

	// 2: Start the VM passing it the plug hole to the plug-in

	TRACE("%#x: StartVM(%s, %d, %#x)\n", GetCurrentThreadId(), achImagePath, m_pImageData, ctx);

	IUnknown* piPlugHole;
	HRESULT hr = static_cast<CComObject<CInProcPlugHole>*>(this)->QueryInterface(&piPlugHole);
	if (FAILED(hr))
	{
		trace("Failed to locate plug hole interface (%#x)\n", hr);
		return hr;
	}

	// Ref. count resulting from above QI is assumed by the image when it retrieves the pointer

	hr = VMEntry(_AtlBaseModule.GetModuleInstance(), m_pImageData, m_cImageSize, achImagePath, 
							piPlugHole, ctx, m_hDolphinThread);
	
	// VMEntry must take a reference to the plug-hole, this just releases the pointer resulting from the QI above
	piPlugHole->Release();

	if (FAILED(hr))
		return hr;

	TRACE("%#x: Started Dolphin main thread %#x...\n", GetCurrentThreadId(), m_hDolphinThread);

	return S_OK;
}
示例#24
0
// Collect all leaked elements, passing them to the specified leak dialog.
//
void JSHook::showLeaks(MSHTML::IHTMLWindow2Ptr wnd, CLeakDlg* dlg) {
	// Ensure that all garbage collection is completed so that elements will
	//   be released.
	//
	wnd->execScript(L"window.CollectGarbage()", L"javascript");

	for (std::map<IUnknown*,Elem>::const_iterator it = m_elements.begin(); it != m_elements.end(); ++it) {
		IUnknown *unk = it->first;
		Elem const& elem = it->second;

		// For each element, AddRef() and Release() it.  The latter method will return
		//   the current ref count.
		//
		unk->AddRef();
		int refCount = unk->Release();

		// If any references (other than the one that we hold) are outstanding, then
		//   the element has been leaked.
		//
		if (refCount > 1)
			dlg->addElement(unk, elem.url, refCount - 1);
	}

	// When finished, clear the element list.
	//
	clearElements();
}
示例#25
0
inline int updateTableCounts(IAccessibleTableCell* tableCell, VBufStorage_buffer_t* tableBuffer) {
	IUnknown* unk = NULL;
	if (tableCell->get_table(&unk) != S_OK || !unk)
		return 0;
	IAccessible2* acc = NULL;
	HRESULT res;
	res = unk->QueryInterface(IID_IAccessible2, (void**)&acc);
	unk->Release();
	if (res != S_OK || !acc)
		return 0;
	int docHandle, id;
	if (acc->get_windowHandle((HWND*)&docHandle) != S_OK
			|| acc->get_uniqueID((long*)&id) != S_OK) {
		acc->Release();
		return 0;
	}
	VBufStorage_controlFieldNode_t* node = tableBuffer->getControlFieldNodeWithIdentifier(docHandle, id);
	if (!node) {
		acc->Release();
		return 0;
	}
	IAccessibleTable2* table = NULL;
	if (acc->QueryInterface(IID_IAccessibleTable2, (void**)&table) != S_OK || !table) {
		acc->Release();
		return 0;
	}
	fillTableCounts<IAccessibleTable2>(node, acc, table);
	table->Release();
	acc->Release();
	return id;
}
STDMETHODIMP CClassFactory::CreateInstance(__in_opt LPUNKNOWN pUnkOuter, __in REFIID riid, __deref_out void **ppv)
{
    *ppv = NULL;

    HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;

    IUnknown *punk = NULL;
    if (_clsid == CLSID_MyDeviceHandlerCollection)
    {
        hr = CMyDeviceHandlerCollection_CreateInstance(pUnkOuter, &punk);
    }
    else if (_clsid == CLSID_MyDeviceContextMenuExt)
    {
        hr = CMyDeviceContextMenu_CreateInstance(pUnkOuter, &punk);
    }
    else if (_clsid == CLSID_MyDeviceHandlerPropertySheetExt)
    {
        hr = CMyDevicePropertySheet_CreateInstance(pUnkOuter, &punk);
    }

    if (SUCCEEDED(hr))
    {
        hr = punk->QueryInterface(riid, ppv);
        punk->Release();
    }

    return hr;

} //*** CClassFactory::CreateInstance
示例#27
0
TestResult __cdecl tstDocument(BrowserInfo &cInfo)
{
	CIPtr(IHTMLDocument2) cpDocElement;
	cInfo.GetDocument(&cpDocElement);
	if (cpDocElement == NULL)
	{
		cInfo.OutputString(_T("Error: No document"));
		return trFailed;
	}

	// Dump out all the interfaces supported by the document element
	for (int i = 0; i < sizeof(aDocIIDs) / sizeof(aDocIIDs[0]); i++)
	{
		IUnknown *pUnkI = NULL;
		if (SUCCEEDED(cpDocElement->QueryInterface(*(aDocIIDs[i].piid), (void **) &pUnkI)))
		{
			cInfo.OutputString(_T("Info: Document supports interface %s"), aDocIIDs[i].szName);
			pUnkI->Release();
		}
		else
		{
			cInfo.OutputString(_T("Info: Document doesn't support interface %s"), aDocIIDs[i].szName);
		}
	}

	return trPassed;
}
STDMETHODIMP touchmind::control::DWriteEditControlTextStoreACP::UnadviseSink(IUnknown *pUnknown) {
  HRESULT hr;
  IUnknown *punkID;

  hr = pUnknown->QueryInterface(IID_IUnknown, (LPVOID *)&punkID);
  if (FAILED(hr)) {
    return hr;
  }

  if (punkID == m_AdviseSink.punkID) {
    _ClearAdviseSink(&m_AdviseSink);

    if (m_pServices) {
      m_pServices->Release();
      m_pServices = nullptr;
    }

    hr = S_OK;
  } else {
    hr = CONNECT_E_NOCONNECTION;
  }

  punkID->Release();
  return hr;
}
示例#29
0
gboolean
gst_dshow_show_propertypage (IBaseFilter * base_filter)
{
  gboolean ret = FALSE;
  ISpecifyPropertyPages *pProp = NULL;
  HRESULT hres =
      base_filter->QueryInterface (IID_ISpecifyPropertyPages, (void **) &pProp);
  if (SUCCEEDED (hres)) {
    /* Get the filter's name and IUnknown pointer. */
    FILTER_INFO FilterInfo;
    CAUUID caGUID;
    IUnknown *pFilterUnk = NULL;
    hres = base_filter->QueryFilterInfo (&FilterInfo);
    base_filter->QueryInterface (IID_IUnknown, (void **) &pFilterUnk);

    /* Show the page. */
    pProp->GetPages (&caGUID);
    pProp->Release ();
    OleCreatePropertyFrame (GetDesktopWindow (), 0, 0, FilterInfo.achName,
        1, &pFilterUnk, caGUID.cElems, caGUID.pElems, 0, 0, NULL);

    pFilterUnk->Release ();
    FilterInfo.pGraph->Release ();
    CoTaskMemFree (caGUID.pElems);
  }
  return ret;
}
示例#30
0
void ComDelete( void *p )
{
	if( p ) {
		IUnknown *unknown = reinterpret_cast<IUnknown*>( p );
		unknown->Release();
	}
}