当前位置: 首页>>代码示例>>C++>>正文


C++ ComPtr::As方法代码示例

本文整理汇总了C++中ComPtr::As方法的典型用法代码示例。如果您正苦于以下问题:C++ ComPtr::As方法的具体用法?C++ ComPtr::As怎么用?C++ ComPtr::As使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ComPtr的用法示例。


在下文中一共展示了ComPtr::As方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnSourceOpen

HRESULT CSchemeHandler::OnSourceOpen(_In_ IMFAsyncResult *pResult)
{
    ComPtr<IUnknown> spState = pResult->GetStateNoAddRef();
    if (!spState)
    {
        return MF_E_UNEXPECTED;
    }
    ComPtr<IMFAsyncResult> spSavedResult;
    HRESULT hr = S_OK;

    hr = spState.As(&spSavedResult);
    if (FAILED(hr))
    {
        TRACEHR_RET(hr);
    }

    ComPtr<IUnknown> spunkSource;
    ComPtr<IMFMediaSource> spSource;
    hr = spSavedResult->GetObject(&spunkSource);

    if (SUCCEEDED(hr))
    {
        hr = spunkSource.As(&spSource);
        if (SUCCEEDED(hr))
        {
            CMediaSource *pSource = static_cast<CMediaSource *>(spSource.Get());
            hr = pSource->EndOpen(pResult);
        }
    }

    spSavedResult->SetStatus(hr);    
    hr = MFInvokeCallback(spSavedResult.Get());

    TRACEHR_RET(hr);
}
开发者ID:mbin,项目名称:Win81App,代码行数:35,代码来源:StspSchemeHandler.cpp

示例2: validateShortcut

bool validateShortcut() {
	QString path = systemShortcutPath();
	if (path.isEmpty() || cExeName().isEmpty()) return false;

	if (cAlphaVersion()) {
		path += qsl("TelegramAlpha.lnk");
		if (validateShortcutAt(path)) return true;
	} else {
		if (validateShortcutAt(path + qsl("Telegram Desktop/Telegram.lnk"))) return true;
		if (validateShortcutAt(path + qsl("Telegram Win (Unofficial)/Telegram.lnk"))) return true;

		path += qsl("Telegram.lnk");
		if (validateShortcutAt(path)) return true;
	}

	ComPtr<IShellLink> shellLink;
	HRESULT hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink));
	if (!SUCCEEDED(hr)) return false;

	hr = shellLink->SetPath(QDir::toNativeSeparators(cExeDir() + cExeName()).toStdWString().c_str());
	if (!SUCCEEDED(hr)) return false;

	hr = shellLink->SetArguments(L"");
	if (!SUCCEEDED(hr)) return false;

	hr = shellLink->SetWorkingDirectory(QDir::toNativeSeparators(QDir(cWorkingDir()).absolutePath()).toStdWString().c_str());
	if (!SUCCEEDED(hr)) return false;

	ComPtr<IPropertyStore> propertyStore;
	hr = shellLink.As(&propertyStore);
	if (!SUCCEEDED(hr)) return false;

	PROPVARIANT appIdPropVar;
	hr = InitPropVariantFromString(getId(), &appIdPropVar);
	if (!SUCCEEDED(hr)) return false;

	hr = propertyStore->SetValue(getKey(), appIdPropVar);
	PropVariantClear(&appIdPropVar);
	if (!SUCCEEDED(hr)) return false;

	PROPVARIANT startPinPropVar;
	hr = InitPropVariantFromUInt32(APPUSERMODEL_STARTPINOPTION_NOPINONINSTALL, &startPinPropVar);
	if (!SUCCEEDED(hr)) return false;

	hr = propertyStore->SetValue(pkey_AppUserModel_StartPinOption, startPinPropVar);
	PropVariantClear(&startPinPropVar);
	if (!SUCCEEDED(hr)) return false;

	hr = propertyStore->Commit();
	if (!SUCCEEDED(hr)) return false;

	ComPtr<IPersistFile> persistFile;
	hr = shellLink.As(&persistFile);
	if (!SUCCEEDED(hr)) return false;

	hr = persistFile->Save(QDir::toNativeSeparators(path).toStdWString().c_str(), TRUE);
	if (!SUCCEEDED(hr)) return false;

	return true;
}
开发者ID:Emadpres,项目名称:tdesktop,代码行数:60,代码来源:windows_app_user_model_id.cpp

示例3:

Frame D3D11VideoRender::CreateFrame(IMFSample * sample, UINT width, UINT height)
{
	// 获取 Buffer 数量
	DWORD bufferCount;
	ThrowIfFailed(sample->GetBufferCount(&bufferCount));

	ComPtr<ID3D11Texture2D> texture;
	for (DWORD i = 0; i < 1; i++)
	{
		ComPtr<IMFMediaBuffer> buffer;
		ThrowIfFailed(sample->GetBufferByIndex(i, &buffer));

		ComPtr<IMFDXGIBuffer> dxgiBuffer;
		if (!SUCCEEDED(buffer.As(&dxgiBuffer)))
		{
			ThrowIfFailed(dxgiBuffer->GetResource(IID_PPV_ARGS(&texture)));
			D3D11_TEXTURE2D_DESC desc;
			texture->GetDesc(&desc);
			desc.Height = desc.Height;
		}
		else
		{
			ComPtr<IMF2DBuffer> buffer2d;
			ThrowIfFailed(buffer.As(&buffer2d));

			DWORD bufferSize;
			ThrowIfFailed(buffer2d->GetContiguousLength(&bufferSize));

			BYTE* base; LONG pitch;
			ThrowIfFailed(buffer2d->Lock2D(&base, &pitch));
			auto fin = make_finalizer([&] { buffer2d->Unlock2D();});

			//width = pitch;
			height = bufferSize / pitch * 2 / 3;

			D3D11_TEXTURE2D_DESC desc{ 0 };
			desc.Width = width;
			desc.Height = height;
			desc.MipLevels = 1;
			desc.ArraySize = 1;
			desc.Format = DXGI_FORMAT_NV12;
			desc.SampleDesc.Count = 1;
			desc.Usage = D3D11_USAGE_IMMUTABLE;
			desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;

			D3D11_SUBRESOURCE_DATA data{ base, static_cast<UINT>(pitch), 0 };
			ThrowIfFailed(d3dDevice->CreateTexture2D(&desc, &data, &texture));
		}
	}
	ComPtr<ID3D11ShaderResourceView> luminanceView, chrominanceView;
	D3D11_SHADER_RESOURCE_VIEW_DESC resDesc = CD3D11_SHADER_RESOURCE_VIEW_DESC(
		texture.Get(), D3D11_SRV_DIMENSION_TEXTURE2D, DXGI_FORMAT_R8_UNORM);
	ThrowIfFailed(d3dDevice->CreateShaderResourceView(texture.Get(), &resDesc, &luminanceView));

	resDesc = CD3D11_SHADER_RESOURCE_VIEW_DESC(
		texture.Get(), D3D11_SRV_DIMENSION_TEXTURE2D, DXGI_FORMAT_R8G8_UNORM);
	ThrowIfFailed(d3dDevice->CreateShaderResourceView(texture.Get(), &resDesc, &chrominanceView));
	return{ luminanceView, chrominanceView };
}
开发者ID:CarzyCarry,项目名称:Tomato.Media,代码行数:59,代码来源:D3D11VideoRender.cpp

示例4: defined

// Configures the Direct3D device, and stores handles to it and the device context.
void DX::DeviceResources::CreateDeviceResources() 
{
    UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;

#ifdef _DEBUG
    creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
#elif defined(PROFILE)
    creationFlags |= D3D11_CREATE_DEVICE_INSTRUMENTED;
#endif

    if (m_fastSemantics)
    {
        creationFlags |= D3D11_CREATE_DEVICE_IMMEDIATE_CONTEXT_FAST_SEMANTICS;
    }

    D3D_FEATURE_LEVEL featureLevels[] = 
    {
        D3D_FEATURE_LEVEL_11_1,
    };

    // Create the Direct3D 11 API device object and a corresponding context.
    ComPtr<ID3D11Device> device;
    ComPtr<ID3D11DeviceContext> context;

    DX::ThrowIfFailed(D3D11CreateDevice(
        nullptr,
        D3D_DRIVER_TYPE_HARDWARE,
        0,
        creationFlags,
        featureLevels,
        _countof(featureLevels),
        D3D11_SDK_VERSION,
        device.GetAddressOf(),      // Returns the Direct3D device created.
        &m_d3dFeatureLevel,         // Returns feature level of device created.
        context.GetAddressOf()      // Returns the device immediate context.
        ));

#ifndef NDEBUG
    ComPtr<ID3D11InfoQueue> d3dInfoQueue;
    if (SUCCEEDED(device.As(&d3dInfoQueue)))
    {
#ifdef _DEBUG
        d3dInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_CORRUPTION, true);
        d3dInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_ERROR, true);
#endif
        D3D11_MESSAGE_ID hide[] =
        {
            D3D11_MESSAGE_ID_SETPRIVATEDATA_CHANGINGPARAMS,
        };
        D3D11_INFO_QUEUE_FILTER filter = {};
        filter.DenyList.NumIDs = _countof(hide);
        filter.DenyList.pIDList = hide;
        d3dInfoQueue->AddStorageFilterEntries(&filter);
    }
#endif

    DX::ThrowIfFailed(device.As(&m_d3dDevice));
    DX::ThrowIfFailed(context.As(&m_d3dContext));
}
开发者ID:walbourn,项目名称:directxtkmodelviewer,代码行数:60,代码来源:DeviceResourcesXDK.cpp

示例5: initialize

bool SwapChainPanelNativeWindow::initialize(EGLNativeWindowType window, IPropertySet *propertySet)
{
    ComPtr<IPropertySet> props = propertySet;
    ComPtr<IInspectable> win = window;
    SIZE swapChainSize = {};
    bool swapChainSizeSpecified = false;
    HRESULT result = S_OK;

    // IPropertySet is an optional parameter and can be null.
    // If one is specified, cache as an IMap and read the properties
    // used for initial host initialization.
    if (propertySet)
    {
        result = props.As(&mPropertyMap);
        if (SUCCEEDED(result))
        {
            // The EGLRenderSurfaceSizeProperty is optional and may be missing.  The IPropertySet
            // was prevalidated to contain the EGLNativeWindowType before being passed to
            // this host.
            result = GetOptionalSizePropertyValue(mPropertyMap, EGLRenderSurfaceSizeProperty, &swapChainSize, &swapChainSizeSpecified);
        }
    }

    if (SUCCEEDED(result))
    {
        result = win.As(&mSwapChainPanel);
    }

    if (SUCCEEDED(result))
    {
        // If a swapchain size is specfied, then the automatic resize
        // behaviors implemented by the host should be disabled.  The swapchain
        // will be still be scaled when being rendered to fit the bounds
        // of the host.
        // Scaling of the swapchain output needs to be handled by the
        // host for swapchain panels even though the scaling mode setting
        // DXGI_SCALING_STRETCH is configured on the swapchain.
        if (swapChainSizeSpecified)
        {
            mClientRect = { 0, 0, swapChainSize.cx, swapChainSize.cy };

            // Enable host swapchain scaling
            mRequiresSwapChainScaling = true;
        }
        else
        {
            result = GetSwapChainPanelSize(mSwapChainPanel, &mClientRect);
        }
    }

    if (SUCCEEDED(result))
    {
        mNewClientRect = mClientRect;
        mClientRectChanged = false;
        return registerForSizeChangeEvents();
    }

    return false;
}
开发者ID:AlexSoehn,项目名称:qt-base-deb,代码行数:59,代码来源:SwapChainPanelNativeWindow.cpp

示例6: validateShortcutAt

bool validateShortcutAt(const QString &path) {
	static const int maxFileLen = MAX_PATH * 10;

	std::wstring p = QDir::toNativeSeparators(path).toStdWString();

	DWORD attributes = GetFileAttributes(p.c_str());
	if (attributes >= 0xFFFFFFF) return false; // file does not exist

	ComPtr<IShellLink> shellLink;
	HRESULT hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink));
	if (!SUCCEEDED(hr)) return false;

	ComPtr<IPersistFile> persistFile;
	hr = shellLink.As(&persistFile);
	if (!SUCCEEDED(hr)) return false;

	hr = persistFile->Load(p.c_str(), STGM_READWRITE);
	if (!SUCCEEDED(hr)) return false;

	ComPtr<IPropertyStore> propertyStore;
	hr = shellLink.As(&propertyStore);
	if (!SUCCEEDED(hr)) return false;

	PROPVARIANT appIdPropVar;
	hr = propertyStore->GetValue(getKey(), &appIdPropVar);
	if (!SUCCEEDED(hr)) return false;

	WCHAR already[MAX_PATH];
	hr = Dlls::PropVariantToString(appIdPropVar, already, MAX_PATH);
	if (SUCCEEDED(hr)) {
		if (std::wstring(getId()) == already) {
			PropVariantClear(&appIdPropVar);
			return true;
		}
	}
	if (appIdPropVar.vt != VT_EMPTY) {
		PropVariantClear(&appIdPropVar);
		return false;
	}
	PropVariantClear(&appIdPropVar);

	hr = InitPropVariantFromString(getId(), &appIdPropVar);
	if (!SUCCEEDED(hr)) return false;

	hr = propertyStore->SetValue(getKey(), appIdPropVar);
	PropVariantClear(&appIdPropVar);
	if (!SUCCEEDED(hr)) return false;

	hr = propertyStore->Commit();
	if (!SUCCEEDED(hr)) return false;

	if (persistFile->IsDirty() == S_OK) {
		persistFile->Save(p.c_str(), TRUE);
	}

	return true;
}
开发者ID:Emadpres,项目名称:tdesktop,代码行数:57,代码来源:windows_app_user_model_id.cpp

示例7: defined

// Configures the Direct3D device, and stores handles to it and the device context.
void StarboardWinRT::DeviceResources::CreateDeviceResources() {
    // This flag adds support for surfaces with a different color channel ordering
    // than the API default. It is required for compatibility with Direct2D.
    UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;

#if defined(_DEBUG)
    if (StarboardWinRT::SdkLayersAvailable()) {
        // If the project is in a debug build, enable debugging via SDK Layers with this flag.
        creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
    }
#endif

    // This array defines the set of DirectX hardware feature levels this app will support.
    // Note the ordering should be preserved.
    // Don't forget to declare your application's minimum required feature level in its
    // description.  All applications are assumed to support 9.1 unless otherwise stated.
    D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0,
                                          D3D_FEATURE_LEVEL_9_3,  D3D_FEATURE_LEVEL_9_2,  D3D_FEATURE_LEVEL_9_1 };

    // Create the Direct3D 11 API device object and a corresponding context.
    ComPtr<ID3D11Device> device;
    ComPtr<ID3D11DeviceContext> context;

    HRESULT hr = D3D11CreateDevice(nullptr, // Specify nullptr to use the default adapter.
                                   D3D_DRIVER_TYPE_HARDWARE, // Create a device using the hardware graphics driver.
                                   0, // Should be 0 unless the driver is D3D_DRIVER_TYPE_SOFTWARE.
                                   creationFlags, // Set debug and Direct2D compatibility flags.
                                   featureLevels, // List of feature levels this app can support.
                                   ARRAYSIZE(featureLevels), // Size of the list above.
                                   D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Store apps.
                                   &device, // Returns the Direct3D device created.
                                   &m_d3dFeatureLevel, // Returns feature level of device created.
                                   &context // Returns the device immediate context.
                                   );

    if (FAILED(hr)) {
        // If the initialization fails, fall back to the WARP device.
        // For more information on WARP, see:
        // http://go.microsoft.com/fwlink/?LinkId=286690
        StarboardWinRT::ThrowIfFailed(D3D11CreateDevice(nullptr,
                                                        D3D_DRIVER_TYPE_WARP, // Create a WARP device instead of a hardware device.
                                                        0,
                                                        creationFlags,
                                                        featureLevels,
                                                        ARRAYSIZE(featureLevels),
                                                        D3D11_SDK_VERSION,
                                                        &device,
                                                        &m_d3dFeatureLevel,
                                                        &context));
    }

    // Store pointers to the Direct3D 11.1 API device and immediate context.
    StarboardWinRT::ThrowIfFailed(device.As(&m_d3dDevice));

    StarboardWinRT::ThrowIfFailed(context.As(&m_d3dContext));
}
开发者ID:Strongc,项目名称:WinObjC,代码行数:57,代码来源:DeviceResources.cpp

示例8: InstallShortcut

// Install the shortcut
HRESULT DesktopToastsApp::InstallShortcut(_In_z_ wchar_t *shortcutPath)
{
    wchar_t exePath[MAX_PATH];
    
    DWORD charWritten = GetModuleFileNameEx(GetCurrentProcess(), nullptr, exePath, ARRAYSIZE(exePath));

    HRESULT hr = charWritten > 0 ? S_OK : E_FAIL;
    
    if (SUCCEEDED(hr))
    {
        ComPtr<IShellLink> shellLink;
        hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink));

        if (SUCCEEDED(hr))
        {
            hr = shellLink->SetPath(exePath);
            if (SUCCEEDED(hr))
            {
                hr = shellLink->SetArguments(L"");
                if (SUCCEEDED(hr))
                {
                    ComPtr<IPropertyStore> propertyStore;

                    hr = shellLink.As(&propertyStore);
                    if (SUCCEEDED(hr))
                    {
                        PROPVARIANT appIdPropVar;
                        hr = InitPropVariantFromString(AppId, &appIdPropVar);
                        if (SUCCEEDED(hr))
                        {
                            hr = propertyStore->SetValue(PKEY_AppUserModel_ID, appIdPropVar);
                            if (SUCCEEDED(hr))
                            {
                                hr = propertyStore->Commit();
                                if (SUCCEEDED(hr))
                                {
                                    ComPtr<IPersistFile> persistFile;
                                    hr = shellLink.As(&persistFile);
                                    if (SUCCEEDED(hr))
                                    {
                                        hr = persistFile->Save(shortcutPath, TRUE);
                                    }
                                }
                            }
                            PropVariantClear(&appIdPropVar);
                        }
                    }
                }
            }
        }
    }
    return hr;
}
开发者ID:chaeyk,项目名称:SoundDeviceToggle,代码行数:54,代码来源:DesktopToastsSample.cpp

示例9: defined

void D3DRenderer::CreateDeviceResources()
{
    // This flag is required in order to enable compatibility with Direct2D
    UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
    ComPtr<IDXGIDevice> dxgiDevice;

#if defined(_DEBUG)
    // If the project is in a debug build, enable debugging via SDK Layers with this flag
    creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

    // This array defines the ordering of feature levels that D3D should attempt to create
    D3D_FEATURE_LEVEL featureLevels[] = 
    {
        D3D_FEATURE_LEVEL_11_1,
        D3D_FEATURE_LEVEL_11_0,
        D3D_FEATURE_LEVEL_10_1,
        D3D_FEATURE_LEVEL_10_0,
        D3D_FEATURE_LEVEL_9_3
    };

    ComPtr<ID3D11Device> device;
    ComPtr<ID3D11DeviceContext> context;
    DX::ThrowIfFailed(
        D3D11CreateDevice(
            nullptr,                    // specify null to use the default adapter
            D3D_DRIVER_TYPE_HARDWARE,
            nullptr,                    // leave as null if hardware is used
            creationFlags,              // optionally set debug and Direct2D compatibility flags
            featureLevels,
            ARRAYSIZE(featureLevels),
            D3D11_SDK_VERSION,          // always set this to D3D11_SDK_VERSION
            &device,
            &m_featureLevel,
            &context
            )
        );

    DX::ThrowIfFailed(
        device.As(&m_d3dDevice)
        );

    DX::ThrowIfFailed(
        context.As(&m_d3dContext)
        );

    // Obtain the underlying DXGI device of the Direct3D device
    DX::ThrowIfFailed(
        m_d3dDevice.As(&dxgiDevice)
        );
}
开发者ID:thaddeusdiamond,项目名称:P8Ball,代码行数:51,代码来源:D3DRenderer.cpp

示例10: defined

// These are the resources that depend on the device.
void Direct3DBase::CreateDeviceResources()
{
	// This flag adds support for surfaces with a different color channel ordering
	// than the API default. It is required for compatibility with Direct2D.
	UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;

#if defined(_DEBUG)
	// If the project is in a debug build, enable debugging via SDK Layers with this flag.
	creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

	// This array defines the set of DirectX hardware feature levels this app will support.
	// Note the ordering should be preserved.
	// Don't forget to declare your application's minimum required feature level in its
	// description.  All applications are assumed to support 9.1 unless otherwise stated.
	D3D_FEATURE_LEVEL featureLevels[] = 
	{
		D3D_FEATURE_LEVEL_11_1,
		D3D_FEATURE_LEVEL_11_0,
		D3D_FEATURE_LEVEL_10_1,
		D3D_FEATURE_LEVEL_10_0,
		D3D_FEATURE_LEVEL_9_3
	};

	// Create the Direct3D 11 API device object and a corresponding context.
	ComPtr<ID3D11Device> device;
	ComPtr<ID3D11DeviceContext> context;
	DX::ThrowIfFailed(
		D3D11CreateDevice(
			nullptr, // Specify nullptr to use the default adapter.
			D3D_DRIVER_TYPE_HARDWARE,
			nullptr,
			creationFlags, // Set set debug and Direct2D compatibility flags.
			featureLevels, // List of feature levels this app can support.
			ARRAYSIZE(featureLevels),
			D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION.
			&device, // Returns the Direct3D device created.
			&m_featureLevel, // Returns feature level of device created.
			&context // Returns the device immediate context.
			)
		);

	// Get the Direct3D 11.1 API device and context interfaces.
	DX::ThrowIfFailed(
		device.As(&m_d3dDevice)
		);

	DX::ThrowIfFailed(
		context.As(&m_d3dContext)
		);
}
开发者ID:Delaire,项目名称:rate-my-app,代码行数:52,代码来源:Direct3DBase.cpp

示例11: DeliverSamples

// Deliver samples for every request client made
void CMediaStream::DeliverSamples()
{
    // Check if we have both: samples available in the queue and requests in request list.
    while (!_samples.IsEmpty() && !_tokens.IsEmpty())
    {
        ComPtr<IUnknown> spEntry;
        ComPtr<IMFSample> spSample;
        ComPtr<IUnknown> spToken;
        BOOL fDrop = FALSE;
        // Get the entry
        ThrowIfError(_samples.RemoveFront(&spEntry));

        if (SUCCEEDED(spEntry.As(&spSample)))
        {
            fDrop = ShouldDropSample(spSample.Get());

            if (!fDrop)
            {
                // Get the request token
                ThrowIfError(_tokens.RemoveFront(&spToken));

                if (spToken)
                {
                    // If token was not null set the sample attribute.
                    ThrowIfError(spSample->SetUnknown(MFSampleExtension_Token, spToken.Get()));
                }

                if (_fDiscontinuity)
                {
                    // If token was not null set the sample attribute.
                    ThrowIfError(spSample->SetUINT32(MFSampleExtension_Discontinuity, TRUE));
                    _fDiscontinuity = false;
                }

                // Send a sample event.
                ThrowIfError(_spEventQueue->QueueEventParamUnk(MEMediaSample, GUID_NULL, S_OK, spSample.Get()));
            }
            else
            {
                _fDiscontinuity = true;
            }
        }
        else
        {
            ComPtr<IMFMediaType> spMediaType;
            ThrowIfError(spEntry.As(&spMediaType));
            // Send a sample event.
            ThrowIfError(_spEventQueue->QueueEventParamUnk(MEStreamFormatChanged, GUID_NULL, S_OK, spMediaType.Get()));
        }
    }
}
开发者ID:01bui,项目名称:Windows-universal-samples,代码行数:52,代码来源:StspMediaStream.cpp

示例12: installShortcut

// Install the shortcut
HRESULT LinkHelper::installShortcut(const std::wstring &shortcutPath,const std::wstring &exePath, const std::wstring &appID)
{
    std::wcout << L"Installing shortcut: " << shortcutPath << L" " << exePath << L" " << appID << std::endl;
    HRESULT hr = S_OK;

    if (SUCCEEDED(hr))
    {
        ComPtr<IShellLink> shellLink;
        hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink));

        if (SUCCEEDED(hr))
        {
            hr = shellLink->SetPath(exePath.c_str());
            if (SUCCEEDED(hr))
            {
                hr = shellLink->SetArguments(L"");
                if (SUCCEEDED(hr))
                {
                    ComPtr<IPropertyStore> propertyStore;

                    hr = shellLink.As(&propertyStore);
                    if (SUCCEEDED(hr))
                    {
                        PROPVARIANT appIdPropVar;
                        hr = InitPropVariantFromString(appID.c_str(), &appIdPropVar);
                        if (SUCCEEDED(hr))
                        {
                            hr = propertyStore->SetValue(PKEY_AppUserModel_ID, appIdPropVar);
                            if (SUCCEEDED(hr))
                            {
                                hr = propertyStore->Commit();
                                if (SUCCEEDED(hr))
                                {
                                    ComPtr<IPersistFile> persistFile;
                                    hr = shellLink.As(&persistFile);
                                    if (SUCCEEDED(hr))
                                    {
                                        hr = persistFile->Save(shortcutPath.c_str(), TRUE);
                                    }
                                }
                            }
                            PropVariantClear(&appIdPropVar);
                        }
                    }
                }
            }
        }
    }
    return hr;
}
开发者ID:dschmidt,项目名称:Snoretoast,代码行数:51,代码来源:linkhelper.cpp

示例13: createIBufferFromData

ComPtr<IBuffer> createIBufferFromData(const char *data, qint32 size)
{
    static ComPtr<IBufferFactory> bufferFactory;
    HRESULT hr;
    if (!bufferFactory) {
        hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Storage_Streams_Buffer).Get(),
                                    IID_PPV_ARGS(&bufferFactory));
        Q_ASSERT_SUCCEEDED(hr);
    }

    ComPtr<IBuffer> buffer;
    const UINT32 length = size;
    hr = bufferFactory->Create(length, &buffer);
    Q_ASSERT_SUCCEEDED(hr);
    hr = buffer->put_Length(length);
    Q_ASSERT_SUCCEEDED(hr);

    ComPtr<Windows::Storage::Streams::IBufferByteAccess> byteArrayAccess;
    hr = buffer.As(&byteArrayAccess);
    Q_ASSERT_SUCCEEDED(hr);

    byte *bytes;
    hr = byteArrayAccess->Buffer(&bytes);
    Q_ASSERT_SUCCEEDED(hr);
    memcpy(bytes, data, length);
    return buffer;
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:27,代码来源:qwinrtdrag.cpp

示例14: Update

// Updates the text to be displayed.
void SampleFpsTextRenderer::Update(DX::StepTimer const& timer)
{
	// Update display text.
	uint32 fps = timer.GetFramesPerSecond();

	m_text = (fps > 0) ? std::to_wstring(fps) + L" FPS" : L" - FPS";

	ComPtr<IDWriteTextLayout> textLayout;
	DX::ThrowIfFailed(
		m_deviceResources->GetDWriteFactory()->CreateTextLayout(
			m_text.c_str(),
			(uint32) m_text.length(),
			m_textFormat.Get(),
			240.0f, // Max width of the input text.
			50.0f, // Max height of the input text.
			&textLayout
			)
		);

	DX::ThrowIfFailed(
		textLayout.As(&m_textLayout)
		);

	DX::ThrowIfFailed(
		m_textLayout->GetMetrics(&m_textMetrics)
		);
}
开发者ID:terriblememory,项目名称:imgui,代码行数:28,代码来源:SampleFpsTextRenderer.cpp

示例15: sizeof

// Initializes D2D resources used for text rendering.
SampleFpsTextRenderer::SampleFpsTextRenderer(const std::shared_ptr<DX::DeviceResources>& deviceResources) : 
	m_text(L""),
	m_deviceResources(deviceResources)
{
	ZeroMemory(&m_textMetrics, sizeof(DWRITE_TEXT_METRICS));

	// Create device independent resources
	ComPtr<IDWriteTextFormat> textFormat;
	DX::ThrowIfFailed(
		m_deviceResources->GetDWriteFactory()->CreateTextFormat(
			L"Segoe UI",
			nullptr,
			DWRITE_FONT_WEIGHT_LIGHT,
			DWRITE_FONT_STYLE_NORMAL,
			DWRITE_FONT_STRETCH_NORMAL,
			32.0f,
			L"en-US",
			&textFormat
			)
		);

	DX::ThrowIfFailed(
		textFormat.As(&m_textFormat)
		);

	DX::ThrowIfFailed(
		m_textFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR)
		);

	DX::ThrowIfFailed(
		m_deviceResources->GetD2DFactory()->CreateDrawingStateBlock(&m_stateBlock)
		);

	CreateDeviceDependentResources();
}
开发者ID:terriblememory,项目名称:imgui,代码行数:36,代码来源:SampleFpsTextRenderer.cpp


注:本文中的ComPtr::As方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。