本文整理汇总了C++中CHECK_HR函数的典型用法代码示例。如果您正苦于以下问题:C++ CHECK_HR函数的具体用法?C++ CHECK_HR怎么用?C++ CHECK_HR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CHECK_HR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CHECK_HR
HRESULT FakeContent::GetValue(
REFPROPERTYKEY Key,
__out IPortableDeviceValues* pStore)
{
HRESULT hr = S_OK;
PropVariantWrapper pvValue;
if(pStore == NULL)
{
hr = E_POINTER;
CHECK_HR(hr, "Cannot have NULL parameter");
return hr;
}
if (IsEqualPropertyKey(Key, WPD_OBJECT_ID))
{
// Add WPD_OBJECT_ID
pvValue = ObjectID;
hr = pStore->SetValue(WPD_OBJECT_ID, &pvValue);
CHECK_HR(hr, ("Failed to set WPD_OBJECT_ID"));
}
else if (IsEqualPropertyKey(Key, WPD_OBJECT_PERSISTENT_UNIQUE_ID))
{
// Add WPD_OBJECT_PERSISTENT_UNIQUE_ID
pvValue = this->PersistentUniqueID;
hr = pStore->SetValue(WPD_OBJECT_PERSISTENT_UNIQUE_ID, &pvValue);
CHECK_HR(hr, ("Failed to set WPD_OBJECT_PERSISTENT_UNIQUE_ID"));
}
else if (IsEqualPropertyKey(Key, WPD_OBJECT_PARENT_ID))
{
// Add WPD_OBJECT_PARENT_ID
pvValue = ParentID;
hr = pStore->SetValue(WPD_OBJECT_PARENT_ID, &pvValue);
CHECK_HR(hr, ("Failed to set WPD_OBJECT_PARENT_ID"));
}
else if (IsEqualPropertyKey(Key, WPD_OBJECT_NAME))
{
// Add WPD_OBJECT_NAME
pvValue = Name;
hr = pStore->SetValue(WPD_OBJECT_NAME, &pvValue);
CHECK_HR(hr, ("Failed to set WPD_OBJECT_NAME"));
}
else if (IsEqualPropertyKey(Key, WPD_OBJECT_CONTENT_TYPE))
{
// Add WPD_OBJECT_CONTENT_TYPE
hr = pStore->SetGuidValue(WPD_OBJECT_CONTENT_TYPE, ContentType);
CHECK_HR(hr, ("Failed to set WPD_OBJECT_CONTENT_TYPE"));
}
else if (IsEqualPropertyKey(Key, WPD_OBJECT_FORMAT))
{
// Add WPD_OBJECT_FORMAT
hr = pStore->SetGuidValue(WPD_OBJECT_FORMAT, Format);
CHECK_HR(hr, ("Failed to set WPD_OBJECT_FORMAT"));
}
else if (IsEqualPropertyKey(Key, WPD_OBJECT_CAN_DELETE))
{
// Add WPD_OBJECT_CAN_DELETE
hr = pStore->SetBoolValue(WPD_OBJECT_CAN_DELETE, CanDelete);
CHECK_HR(hr, ("Failed to set WPD_OBJECT_CAN_DELETE"));
}
else
{
hr = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
CHECK_HR(hr, "Property {%ws}.%d is not supported", CComBSTR(Key.fmtid), Key.pid);
}
return hr;
}
示例2: CHECK_HR
//---------------------------------------------------------------------------
// wxActiveXContainer::CreateActiveX
//
// Actually creates the ActiveX container through the FrameSite
// and sets up ActiveX events
//
// TODO: Document this more
//---------------------------------------------------------------------------
void wxActiveXContainer::CreateActiveX(REFIID iid, IUnknown* pUnk)
{
HRESULT hret;
hret = m_ActiveX.QueryInterface(iid, pUnk);
CHECK_HR(hret);
// FrameSite
m_frameSite = new FrameSite(m_realparent, this);
// oleClientSite
hret = m_clientSite.QueryInterface(
IID_IOleClientSite, (IDispatch *) m_frameSite);
CHECK_HR(hret);
// adviseSink
wxAutoIAdviseSink adviseSink(IID_IAdviseSink, (IDispatch *) m_frameSite);
wxASSERT(adviseSink.IsOk());
// Get Dispatch interface
hret = m_Dispatch.QueryInterface(IID_IDispatch, m_ActiveX);
CHECK_HR(hret);
//
// SETUP TYPEINFO AND ACTIVEX EVENTS
//
// get type info via class info
wxAutoIProvideClassInfo classInfo(IID_IProvideClassInfo, m_ActiveX);
wxASSERT(classInfo.IsOk());
// type info
wxAutoITypeInfo typeInfo;
hret = classInfo->GetClassInfo(typeInfo.GetRef());
CHECK_HR(hret);
wxASSERT(typeInfo.IsOk());
// TYPEATTR
TYPEATTR *ta = NULL;
hret = typeInfo->GetTypeAttr(&ta);
CHECK_HR(hret);
// this should be a TKIND_COCLASS
wxASSERT(ta->typekind == TKIND_COCLASS);
// iterate contained interfaces
for (int i = 0; i < ta->cImplTypes; i++)
{
HREFTYPE rt = 0;
// get dispatch type info handle
hret = typeInfo->GetRefTypeOfImplType(i, &rt);
if (! SUCCEEDED(hret))
continue;
// get dispatch type info interface
wxAutoITypeInfo ti;
hret = typeInfo->GetRefTypeInfo(rt, ti.GetRef());
if (! ti.IsOk())
continue;
CHECK_HR(hret);
// check if default event sink
bool defEventSink = false;
int impTypeFlags = 0;
typeInfo->GetImplTypeFlags(i, &impTypeFlags);
if (impTypeFlags & IMPLTYPEFLAG_FDEFAULT)
{
if (impTypeFlags & IMPLTYPEFLAG_FSOURCE)
{
// WXOLE_TRACEOUT("Default Event Sink");
defEventSink = true;
if (impTypeFlags & IMPLTYPEFLAG_FDEFAULTVTABLE)
{
// WXOLE_TRACEOUT("*ERROR* - Default Event Sink is via vTable");
defEventSink = false;
wxFAIL_MSG(wxT("Default event sink is in vtable!"));
}
}
}
// wxAutoOleInterface<> assumes a ref has already been added
// TYPEATTR
TYPEATTR *ta = NULL;
hret = ti->GetTypeAttr(&ta);
CHECK_HR(hret);
if (ta->typekind == TKIND_DISPATCH)
{
// WXOLE_TRACEOUT("GUID = " << GetIIDName(ta->guid).c_str());
if (defEventSink)
{
//.........这里部分代码省略.........
示例3: CheckPointer
HRESULT StaticSourceVideoPin::FillBuffer(IMediaSample * pSample)
{
CheckPointer(pSample, E_POINTER);
HRESULT hr = S_OK;
DWORD frameDataCount;
BYTE * frameData;
//Nastavenie hodnoty casu zaciatku a konca snimky
REFERENCE_TIME rtStart = this->m_rtLastFrame;
REFERENCE_TIME rtStop = rtStart + this->m_pFilter->m_params->m_rtFrameLength;
pSample->SetTime(&rtStart, &rtStop);
if (this->m_pFilter->m_rtStop > 0 && rtStop >= this->m_pFilter->m_rtStop)
{
//Ak je nastaveny cas konca a prekroci sa, ukonci sa stream
hr = S_FALSE;
goto done;
}
this->m_rtLastFrame = rtStop;
CHECK_HR(hr = pSample->GetPointer(&frameData));
frameDataCount = pSample->GetSize();
//Ak je nastavena bitmapa, pouzi tu, inak nastav sum
if (this->m_pFilter->m_params->m_bitmapData == NULL)
{
for (DWORD i = 0; i < frameDataCount; i++)
frameData[i] = (BYTE)(rand() % 256);
}
else
{
if (this->m_mt.subtype == MEDIASUBTYPE_RGB32)
{
//Na vystup ide RGB32 typ
if (this->m_pFilter->m_params->m_bitmapInfo.biBitCount == 32)
{
CopyMemory(frameData, this->m_pFilter->m_params->m_bitmapData, frameDataCount);
}
else
{
BITMAPINFOHEADER dstBmi = this->m_pFilter->m_params->m_bitmapInfo;
dstBmi.biBitCount = 32;
RGBtoRGB(this->m_pFilter->m_params->m_bitmapInfo, this->m_pFilter->m_params->m_bitmapData, frameData, dstBmi);
}
}
else if (this->m_mt.subtype == MEDIASUBTYPE_RGB24)
{
//Na vystup ide RGB24 typ
if (this->m_pFilter->m_params->m_bitmapInfo.biBitCount == 24)
{
CopyMemory(frameData, this->m_pFilter->m_params->m_bitmapData, frameDataCount);
}
else
{
BITMAPINFOHEADER dstBmi = this->m_pFilter->m_params->m_bitmapInfo;
dstBmi.biBitCount = 24;
RGBtoRGB(this->m_pFilter->m_params->m_bitmapInfo, this->m_pFilter->m_params->m_bitmapData, frameData, dstBmi);
}
}
else if (this->m_mt.subtype == MEDIASUBTYPE_YUY2)
{
//Na vystup ide YUY2 typ
RGBtoYUY2(this->m_pFilter->m_params->m_bitmapInfo, this->m_pFilter->m_params->m_bitmapData, frameData);
}
else if (this->m_mt.subtype == MEDIASUBTYPE_YV12)
{
//Na vystup ide YV12 typ
RGBtoYV12(this->m_pFilter->m_params->m_bitmapInfo, this->m_pFilter->m_params->m_bitmapData, frameData);
}
}
CHECK_HR(hr = pSample->SetSyncPoint(TRUE));
CHECK_HR(hr = pSample->SetActualDataLength(frameDataCount));
done:
return hr;
}
示例4: CHECK_HR
/**
* This method is called when we receive a WPD_COMMAND_OBJECT_RESOURCES_READ
* command.
*
* The parameters sent to us are:
* - WPD_PROPERTY_OBJECT_RESOURCES_CONTEXT: the context the driver returned to
* the client in OnOpenResource.
* - WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_TO_READ: the number of bytes to
* read from the resource.
*
* The driver should:
* - Read data associated with the resource and return it back to the caller in
* WPD_PROPERTY_OBJECT_RESOURCES_DATA.
* - Report the number of bytes actually read from the resource in
* WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_READ. This number may be smaller
* than WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_TO_READ when reading the last
* chunk of data from the resource.
*/
HRESULT WpdObjectResources::OnReadResource(
_In_ IPortableDeviceValues* pParams,
_In_ IPortableDeviceValues* pResults)
{
HRESULT hr = S_OK;
LPWSTR wszResourceContext = NULL;
DWORD dwNumBytesToRead = 0;
DWORD dwNumBytesRead = 0;
BYTE* pBuffer = NULL;
WpdObjectResourceContext* pResourceContext = NULL;
ContextMap* pContextMap = NULL;
// Get the enumeration context identifier for this enumeration operation. We will
// need this to lookup the specific enumeration context in the client context map.
hr = pParams->GetStringValue(WPD_PROPERTY_OBJECT_RESOURCES_CONTEXT, &wszResourceContext);
if (hr != S_OK)
{
hr = E_INVALIDARG;
CHECK_HR(hr, "Missing value for WPD_PROPERTY_OBJECT_RESOURCES_CONTEXT");
}
// Get the number of bytes to read
if (hr == S_OK)
{
hr = pParams->GetUnsignedIntegerValue(WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_TO_READ, &dwNumBytesToRead);
CHECK_HR(hr, "Missing value for WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_TO_READ");
}
// Allocate the destination buffer
if (hr == S_OK)
{
pBuffer = reinterpret_cast<BYTE *>(CoTaskMemAlloc(dwNumBytesToRead));
if (pBuffer == NULL)
{
hr = E_OUTOFMEMORY;
CHECK_HR(hr, "Failed to allocate the destination buffer");
}
}
// Get the client context map so we can retrieve the resource context for this resource
// operation using the WPD_PROPERTY_OBJECT_RESOURCES_CONTEXT property value obtained above.
if (hr == S_OK)
{
hr = pParams->GetIUnknownValue(PRIVATE_SAMPLE_DRIVER_CLIENT_CONTEXT_MAP, (IUnknown**)&pContextMap);
CHECK_HR(hr, "Failed to get PRIVATE_SAMPLE_DRIVER_CLIENT_CONTEXT_MAP");
}
if (hr == S_OK)
{
pResourceContext = (WpdObjectResourceContext*)pContextMap->GetContext(wszResourceContext);
if (pResourceContext == NULL)
{
hr = E_INVALIDARG;
CHECK_HR(hr, "Missing resource context");
}
}
// Read the next chunk of data for this request
if (hr == S_OK && pBuffer != NULL)
{
hr = ReadDataFromResource(pResourceContext, pBuffer, dwNumBytesToRead, &dwNumBytesRead);
CHECK_HR(hr, "Failed to read %d bytes from resource", dwNumBytesToRead);
}
if (hr == S_OK && pBuffer != NULL)
{
hr = pResults->SetBufferValue(WPD_PROPERTY_OBJECT_RESOURCES_DATA, pBuffer, dwNumBytesRead);
CHECK_HR(hr, "Failed to set WPD_PROPERTY_OBJECT_RESOURCES_DATA");
}
if (hr == S_OK)
{
hr = pResults->SetUnsignedIntegerValue(WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_READ, dwNumBytesRead);
CHECK_HR(hr, "Failed to set WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_READ");
}
// Free the memory. CoTaskMemFree ignores NULLs so no need to check.
CoTaskMemFree(wszResourceContext);
// Free the memory. CoTaskMemFree ignores NULLs so no need to check.
CoTaskMemFree(pBuffer);
//.........这里部分代码省略.........
示例5: main
int main()
{
UINT dpi = SetupDPI();
gRenderScale = 96.0 / double(dpi);
// Scale default window size based on dpi
gWindowWidth *= dpi / 96;
gWindowHeight *= dpi / 96;
// Create window
{
WNDCLASSEX wc;
ZeroMemory(&wc, sizeof(wc));
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = MyWndProc;
wc.hInstance = GetModuleHandle(NULL);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
wc.lpszClassName = TEXT("WindowClass");
CHECK_WIN32(RegisterClassEx(&wc));
RECT wr = { 0, 0, gWindowWidth, gWindowHeight };
CHECK_WIN32(AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE));
ghWnd = CHECK_WIN32(CreateWindowEx(
0, TEXT("WindowClass"),
TEXT("Spooky"), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, wr.right - wr.left, wr.bottom - wr.top,
0, 0, GetModuleHandle(NULL), 0));
}
// Create D3D11 device and swap chain
{
ComPtr<IDXGIFactory> pFactory;
CHECK_HR(CreateDXGIFactory(IID_PPV_ARGS(&pFactory)));
UINT deviceFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#ifdef _DEBUG
deviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
RECT clientRect;
GetClientRect(ghWnd, &clientRect);
DXGI_SWAP_CHAIN_DESC scd{};
scd.BufferCount = kSwapChainBufferCount;
scd.BufferDesc.Format = kSwapChainFormat;
scd.BufferDesc.Width = clientRect.right - clientRect.left;
scd.BufferDesc.Height = clientRect.bottom - clientRect.top;
scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
scd.OutputWindow = ghWnd;
scd.Windowed = TRUE;
scd.SampleDesc.Count = 1;
scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
CHECK_HR(D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, deviceFlags, NULL, 0, D3D11_SDK_VERSION, &scd, &gpSwapChain, &gpDevice, NULL, &gpDeviceContext));
CHECK_HR(gpDevice.As(&gpDxgiDevice));
}
InitApp(dpi);
ShowWindow(ghWnd, SW_SHOWNORMAL);
EnableMouseInPointer(TRUE);
while (!gShouldClose)
{
// Handle all events
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
UpdateApp();
RenderApp();
// Swap buffers
CHECK_HR(gpSwapChain->Present(0, 0));
}
CoUninitialize(); // <- this currently creates problems with the WIC Factory.
CHECK_HR(gpSwapChain->SetFullscreenState(FALSE, NULL));
}
示例6: CHECK_HR
/**
* This method is called when we receive a WPD_COMMAND_OBJECT_PROPERTIES_BULK_SET_VALUES_BY_OBJECT_LIST_NEXT
* command.
*
* The parameters sent to us are:
* - WPD_PROPERTY_OBJECT_PROPERTIES_BULK_CONTEXT: the context the driver returned to
* the client in OnGetValuesByObjectListStart.
*
* The driver should:
* - Write the next set of property values, and return the write results in WPD_PROPERTY_OBJECT_PROPERTIES_BULK_WRITE_RESULTS.
* If there are no more properties to be written, an empty collection should be returned.
* - It is up to the driver to write as many object property values as it wants. If zero write results are returned
* it is assumed the bulk operation is complete and the WPD_COMMAND_OBJECT_PROPERTIES_BULK_SET_VALUES_BY_OBJECT_LIST_END
* will be called next.
*
* - S_OK should be returned if the collection can be returned successfully.
* - Any error return indicates that the driver did not fill in any results, and the caller will
* not attempt to unpack any property values.
*/
HRESULT WpdObjectPropertiesBulk::OnSetValuesByObjectListNext(
_In_ IPortableDeviceValues* pParams,
_In_ IPortableDeviceValues* pResults)
{
HRESULT hr = S_OK;
LPWSTR pwszContext = NULL;
BulkPropertiesContext* pContext = NULL;
DWORD cObjects = 0;
CComPtr<IPortableDeviceValues> pEventParams;
CComPtr<IPortableDeviceValuesCollection> pWriteResults;
CComPtr<IPortableDeviceValuesCollection> pValuesCollection;
hr = pParams->GetStringValue(WPD_PROPERTY_OBJECT_PROPERTIES_BULK_CONTEXT, &pwszContext);
CHECK_HR(hr, "Failed to get WPD_PROPERTY_OBJECT_PROPERTIES_BULK_CONTEXT from IPortableDeviceValues");
// Get the bulk property operation context
if (SUCCEEDED(hr))
{
hr = GetClientContext(pParams, pwszContext, (IUnknown**) &pContext);
CHECK_HR(hr, "Failed to get bulk property context");
}
// Make sure the the collection holds a ValuesCollection, then get the number of elements.
if (SUCCEEDED(hr))
{
if(pContext->ValuesCollection != NULL)
{
hr = pContext->ValuesCollection->GetCount(&cObjects);
CHECK_HR(hr, "Failed to get number of objectIDs from bulk properties context");
}
else
{
hr = E_INVALIDARG;
CHECK_HR(hr, "Incorrect context specified - this context does not contain a values collection");
}
}
// Create the collection to hold the write results
if (SUCCEEDED(hr))
{
hr = CoCreateInstance(CLSID_PortableDeviceValuesCollection,
NULL,
CLSCTX_INPROC_SERVER,
IID_IPortableDeviceValuesCollection,
(VOID**) &pWriteResults);
CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValuesCollection");
}
// Create the collection to hold the event parameters
if (SUCCEEDED(hr))
{
hr = CoCreateInstance(CLSID_PortableDeviceValues,
NULL,
CLSCTX_INPROC_SERVER,
IID_IPortableDeviceValues,
(VOID**) &pEventParams);
CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
}
if (SUCCEEDED(hr))
{
for (DWORD dwIndex = pContext->NextObject; dwIndex < cObjects; dwIndex++)
{
CComPtr<IPortableDeviceValues> pValues;
CComPtr<IPortableDeviceValues> pSetResults;
bool bObjectChanged = false;
hr = pContext->ValuesCollection->GetAt(dwIndex, &pValues);
CHECK_HR(hr, "Failed to get next values from bulk properties context");
// CoCreate a collection to store the per object results.
if (SUCCEEDED(hr))
{
hr = CoCreateInstance(CLSID_PortableDeviceValues,
NULL,
CLSCTX_INPROC_SERVER,
IID_IPortableDeviceValues,
(VOID**) &pSetResults);
CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
}
//.........这里部分代码省略.........
示例7: CHECK_HR
HRESULT WpdServiceMethods::DispatchMethod(
_In_ LPCWSTR pwszContext,
_In_ IPortableDeviceValues* pStartParams,
_Outptr_ IPortableDeviceValues** ppResults)
{
HRESULT hr = S_OK;
HRESULT hrStatus = S_OK;
GUID Method = GUID_NULL;
CComPtr<IPortableDeviceValues> pMethodParams;
CComPtr<IPortableDeviceValues> pMethodResults;
*ppResults = NULL;
// Get the method GUID
hr = pStartParams->GetGuidValue(WPD_PROPERTY_SERVICE_METHOD, &Method);
CHECK_HR(hr, "Failed to get WPD_PROPERTY_SERVICE_METHOD");
// Get the method parameters. These can be optional if the methods don't require parameters
if (hr == S_OK)
{
HRESULT hrTemp = pStartParams->GetIPortableDeviceValuesValue(WPD_PROPERTY_SERVICE_METHOD_PARAMETER_VALUES, &pMethodParams);
CHECK_HR(hrTemp, "Failed to get WPD_PROPERTY_SERVICE_METHOD_PARAMETER_VALUES (ok if method does not require parameters)");
}
// Prepare the results collection
if (hr == S_OK)
{
hr = CoCreateInstance(CLSID_PortableDeviceValues,
NULL,
CLSCTX_INPROC_SERVER,
IID_IPortableDeviceValues,
(VOID**)ppResults);
CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
}
if (hr == S_OK)
{
// Invoke the method to the service
m_pGattService->OnMethodInvoke(Method, pMethodParams, *ppResults);
}
// Post the completion event if the method has failed.
{
if (hr == S_OK)
{
hr = (*ppResults)->SetGuidValue(WPD_EVENT_PARAMETER_EVENT_ID, WPD_EVENT_SERVICE_METHOD_COMPLETE);
CHECK_HR(hr, "Failed to set the event id to WPD_EVENT_SERVICE_METHOD_COMPLETE");
}
if (hr == S_OK)
{
hr = (*ppResults)->SetStringValue(WPD_EVENT_PARAMETER_SERVICE_METHOD_CONTEXT, pwszContext);
CHECK_HR(hr, "Failed to set the method context for WPD_EVENT_SERVICE_METHOD_COMPLETE");
}
if (hr == S_OK)
{
hr = PostWpdEvent(pStartParams, *ppResults);
CHECK_HR(hr, "Failed to post WPD_EVENT_SERVICE_METHOD_COMPLETE");
}
}
if (hr == S_OK)
{
hr = hrStatus;
}
return hr;
}
示例8: XCHECK_HR
/////////////////////////////////////////////////////////////////
// myGetProperty
//
// This function gets the BOOL value for the specified property
// and returns the result in *pbValue.
//
/////////////////////////////////////////////////////////////////
HRESULT myGetProperty
(
IUnknown * pIUnknown,
REFIID riid,
DBPROPID dwPropertyID,
REFGUID guidPropertySet,
BOOL * pbValue
)
{
HRESULT hr;
DBPROPID rgPropertyIDs[1];
DBPROPIDSET rgPropertyIDSets[1];
ULONG cPropSets = 0;
DBPROPSET * rgPropSets = NULL;
IDBProperties * pIDBProperties = NULL;
ISessionProperties * pISesProps = NULL;
ICommandProperties * pICmdProps = NULL;
IRowsetInfo * pIRowsetInfo = NULL;
// Initialize the output value
*pbValue = FALSE;
// Set up the property ID array
rgPropertyIDs[0] = dwPropertyID;
// Set up the Property ID Set
rgPropertyIDSets[0].rgPropertyIDs = rgPropertyIDs;
rgPropertyIDSets[0].cPropertyIDs = 1;
rgPropertyIDSets[0].guidPropertySet = guidPropertySet;
// Get the property value for this property from the provider, but
// don't try to display extended error information, since this may
// not be a supported property: a failure is, in fact, expected if
// the property is not supported
if( riid == IID_IDBProperties )
{
XCHECK_HR(hr = pIUnknown->QueryInterface(IID_IDBProperties,
(void**)&pIDBProperties));
CHECK_HR(hr = pIDBProperties->GetProperties(
1, //cPropertyIDSets
rgPropertyIDSets, //rgPropertyIDSets
&cPropSets, //pcPropSets
&rgPropSets //prgPropSets
));
}
else if( riid == IID_ISessionProperties )
{
XCHECK_HR(hr = pIUnknown->QueryInterface(IID_ISessionProperties,
(void**)&pISesProps));
CHECK_HR(hr = pISesProps->GetProperties(
1, //cPropertyIDSets
rgPropertyIDSets, //rgPropertyIDSets
&cPropSets, //pcPropSets
&rgPropSets //prgPropSets
));
}
else if( riid == IID_ICommandProperties )
{
XCHECK_HR(hr = pIUnknown->QueryInterface(IID_ICommandProperties,
(void**)&pICmdProps));
CHECK_HR(hr = pICmdProps->GetProperties(
1, //cPropertyIDSets
rgPropertyIDSets, //rgPropertyIDSets
&cPropSets, //pcPropSets
&rgPropSets //prgPropSets
));
}
else
{
XCHECK_HR(hr = pIUnknown->QueryInterface(IID_IRowsetInfo,
(void**)&pIRowsetInfo));
CHECK_HR(hr = pIRowsetInfo->GetProperties(
1, //cPropertyIDSets
rgPropertyIDSets, //rgPropertyIDSets
&cPropSets, //pcPropSets
&rgPropSets //prgPropSets
));
}
// Return the value for this property to the caller if
// it's a VT_BOOL type value, as expected
if( V_VT(&rgPropSets[0].rgProperties[0].vValue) == VT_BOOL )
*pbValue = V_BOOL(&rgPropSets[0].rgProperties[0].vValue);
CLEANUP:
if( rgPropSets )
{
CoTaskMemFree(rgPropSets[0].rgProperties);
CoTaskMemFree(rgPropSets);
}
if( pIDBProperties )
//.........这里部分代码省略.........
示例9: SetPortState
/*-----------------------------------------------------------------------------
FUNCTION: SetPortState( void )
PURPOSE: Sets port state based on settings from the user
COMMENTS: Sets up DCB structure and calls SetCommState.
Sets up new timeouts by calling SetCommTimeouts.
HISTORY: Date: Author: Comment:
1/9/96 AllenD Wrote it
12/06/06 DonnMo Replaced calls to ErrorReporter() with CHECK_HR()
-----------------------------------------------------------------------------*/
HRESULT RS232Connection::SetPortState()
{
HRESULT hr = S_OK;
DCB dcb = {0};
DWORD dwLastError = 0;
dcb.DCBlength = sizeof(dcb);
//
// get current DCB settings
//
if (!GetCommState(m_hCommPort, &dcb))
{
dwLastError = GetLastError();
hr = HRESULT_FROM_WIN32(dwLastError);
CHECK_HR(hr, "GetCommState() failed within SetPortState().");
return hr;
}
//
// update DCB rate, byte size, parity, and stop bits size
//
dcb.BaudRate = m_dwBaudRate;
dcb.ByteSize = m_bByteSize;
dcb.Parity = m_bParity;
dcb.StopBits = m_bStopBits;
//
// update event flags
//
if (m_dwEventFlags & EV_RXFLAG)
{
dcb.EvtChar = m_chFlag;
}
else
{
dcb.EvtChar = '\0';
}
dcb.EofChar = '\n';
//
// update flow control settings
//
dcb.fDtrControl = m_fDtrControl;
dcb.fRtsControl = m_fRtsControl;
dcb.fOutxCtsFlow = m_fCTSOutFlow;
dcb.fOutxDsrFlow = m_fDSROutFlow;
dcb.fDsrSensitivity = m_fDSRInFlow;
dcb.fOutX = m_fXonXoffOutFlow;
dcb.fInX = m_fXonXoffInFlow;
dcb.fTXContinueOnXoff = m_fTXafterXoffSent;
dcb.XonChar = m_chXON;
dcb.XoffChar = m_chXOFF;
dcb.XonLim = m_wXONLimit;
dcb.XoffLim = m_wXOFFLimit;
//
// DCB settings not in the user's control
//
dcb.fParity = TRUE;
//
// set new state
//
if (!SetCommState(m_hCommPort, &dcb))
{
dwLastError = GetLastError();
hr = HRESULT_FROM_WIN32(dwLastError);
CHECK_HR(hr, "SetCommState() failed within SetPortState() when setting the new state.");
return hr;
}
//
// set new timeouts
//
if (!SetCommTimeouts(m_hCommPort, &m_timeoutsnew))
{
dwLastError = GetLastError();
hr = HRESULT_FROM_WIN32(dwLastError);
CHECK_HR(hr, "SetCommTimeouts() failed within SetPortState() when setting the new timeouts.");
return hr;
}
//.........这里部分代码省略.........
示例10: CHECK_HR
HRESULT CMFCamCapture::init()
{
IMFMediaType *pType = NULL;
HRESULT hr;
CHECK_HR(hr = CoInitializeEx(NULL, COINIT_MULTITHREADED));
CHECK_HR(hr = MFStartup(MF_VERSION));
// Configure the media type that the Sample Grabber will receive.
// Setting the major and subtype is usually enough for the topology loader
// to resolve the topology.
CHECK_HR(hr = MFCreateMediaType(&pType));
CHECK_HR(hr = pType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video));
CHECK_HR(hr = pType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_RGB24));
// Create the sample grabber sink.
CHECK_HR(hr = SampleGrabberCB::CreateInstance(&m_spSampleGrabber));
CHECK_HR(hr = MFCreateSampleGrabberSinkActivate(pType, m_spSampleGrabber, &m_spSinkActivate));
// To run as fast as possible, set this attribute (requires Windows 7):
CHECK_HR(hr = m_spSinkActivate->SetUINT32(MF_SAMPLEGRABBERSINK_IGNORE_CLOCK, TRUE));
// Create the Media Session.
CHECK_HR(hr = MFCreateMediaSession(NULL, &m_spSession));
CHECK_HR(hr = enumVideoDevices());
CHECK_HR(hr = setupVideoDevice());
CHECK_HR(hr = setupMfSession());
done:
SafeRelease(&pType);
return hr;
}
示例11: Connect
/*-----------------------------------------------------------------------------
FUNCTION: Connect( void )
PURPOSE: Setup Communication Port with our settings
RETURN:
S_OK and handle of com port if successful
-----------------------------------------------------------------------------*/
HRESULT RS232Connection::Connect(_In_ LPCWSTR wszPortName, _Out_ HANDLE *phCommPort)
{
HRESULT hr = S_OK;
DWORD dwLastError = 0;
if (phCommPort == NULL)
{
hr = E_POINTER;
CHECK_HR(hr, "A NULL phCommPort parameter was received");
return hr;
}
*phCommPort = NULL;
//
// retrieve a handle for the com port
// and configure the port for asynchronous
// communications.
//
m_hCommPort = CreateFileW(wszPortName,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
0);
if (m_hCommPort == NULL)
{
dwLastError = GetLastError();
hr = HRESULT_FROM_WIN32(dwLastError);
CHECK_HR(hr, "CreateFileW() failed in RS232Connection::Connect");
return hr;
}
//
// Save original comm timeouts and set new ones
//
if (!GetCommTimeouts( m_hCommPort, &(m_timeoutsorig)))
{
dwLastError = GetLastError();
hr = HRESULT_FROM_WIN32(dwLastError);
CHECK_HR(hr, "GetCommTimeouts() failed within RS232Connection::Connect");
return hr;
}
//
// Set port state
//
hr = SetPortState();
if (FAILED(hr))
{
CHECK_HR(hr, "SetPortState() failed within RS232Connection::Connect");
return hr;
}
//
// set comm buffer sizes
//
if (!SetupComm(m_hCommPort, MAX_READ_BUFFER, MAX_WRITE_BUFFER))
{
dwLastError = GetLastError();
hr = HRESULT_FROM_WIN32(dwLastError);
CHECK_HR(hr, "SetupComm(SETDTR) failed within RS232Connection::Connect");
return hr;
}
//
// raise DTR
//
if (!EscapeCommFunction(m_hCommPort, SETDTR))
{
dwLastError = GetLastError();
hr = HRESULT_FROM_WIN32(dwLastError);
CHECK_HR(hr, "EscapeCommFunction() failed within RS232Connection::Connect");
return hr;
}
//
// set overall connect flag
//
m_fConnected = TRUE;
//
// set the return value
//
*phCommPort = m_hCommPort;
if (SUCCEEDED(hr))
//.........这里部分代码省略.........
示例12: CHECK_HR
HRESULT WpdBaseDriver::DispatchWpdMessage(_In_ IPortableDeviceValues* pParams,
_In_ IPortableDeviceValues* pResults)
{
HRESULT hr = S_OK;
GUID guidCommandCategory = {0};
DWORD dwCommandID = 0;
PROPERTYKEY CommandKey = WPD_PROPERTY_NULL;
if (hr == S_OK)
{
hr = pParams->GetGuidValue(WPD_PROPERTY_COMMON_COMMAND_CATEGORY, &guidCommandCategory);
CHECK_HR(hr, "Failed to get WPD_PROPERTY_COMMON_COMMAND_CATEGORY from input parameters");
}
if (hr == S_OK)
{
hr = pParams->GetUnsignedIntegerValue(WPD_PROPERTY_COMMON_COMMAND_ID, &dwCommandID);
CHECK_HR(hr, "Failed to get WPD_PROPERTY_COMMON_COMMAND_ID from input parameters");
}
// If WPD_PROPERTY_COMMON_COMMAND_CATEGORY or WPD_PROPERTY_COMMON_COMMAND_ID could not be extracted
// properly then we should return E_INVALIDARG to the client.
if (FAILED(hr))
{
hr = E_INVALIDARG;
CHECK_HR(hr, "Failed to get WPD_PROPERTY_COMMON_COMMAND_CATEGORY or WPD_PROPERTY_COMMON_COMMAND_ID from input parameters");
}
if (hr == S_OK)
{
CommandKey.fmtid = guidCommandCategory;
CommandKey.pid = dwCommandID;
if (CommandKey.fmtid == WPD_CATEGORY_OBJECT_ENUMERATION)
{
hr = m_ObjectEnum.DispatchWpdMessage(CommandKey, pParams, pResults);
}
else if (CommandKey.fmtid == WPD_CATEGORY_OBJECT_PROPERTIES)
{
hr = m_ObjectProperties.DispatchWpdMessage(CommandKey, pParams, pResults);
}
else if (CommandKey.fmtid == WPD_CATEGORY_OBJECT_RESOURCES)
{
hr = m_ObjectResources.DispatchWpdMessage(CommandKey, pParams, pResults);
}
else if (CommandKey.fmtid == WPD_CATEGORY_CAPABILITIES)
{
hr = m_Capabilities.DispatchWpdMessage(CommandKey, pParams, pResults);
}
else if (IsEqualPropertyKey(CommandKey, WPD_COMMAND_COMMON_GET_OBJECT_IDS_FROM_PERSISTENT_UNIQUE_IDS))
{
hr = OnGetObjectIDsFromPersistentUniqueIDs(pParams, pResults);
}
else
{
hr = E_NOTIMPL;
CHECK_HR(hr, "Unknown command %ws.%d received",CComBSTR(CommandKey.fmtid), CommandKey.pid);
}
}
HRESULT hrTemp = pResults->SetErrorValue(WPD_PROPERTY_COMMON_HRESULT, hr);
CHECK_HR(hrTemp, ("Failed to set WPD_PROPERTY_COMMON_HRESULT"));
// Set to a success code, to indicate that the message was received.
// the return code for the actual command's results is stored in the
// WPD_PROPERTY_COMMON_HRESULT property.
hr = S_OK;
return hr;
}
示例13: CHECK_HR
HRESULT WpdObjectPropertiesBulk::CreateBulkPropertiesContext(
__in ACCESS_SCOPE Scope,
__inout ContextMap* pContextMap,
__in REFGUID guidObjectFormat,
__in LPCWSTR pszParentObjectID,
__in DWORD dwDepth,
__in IPortableDeviceKeyCollection* pProperties,
__deref_out_opt LPWSTR* ppszBulkPropertiesContext)
{
HRESULT hr = S_OK;
BulkPropertiesContext* pContext = NULL;
CAtlStringW strKey;
CComPtr<IPortableDevicePropVariantCollection> pObjectIDs;
if((pContextMap == NULL) ||
(pszParentObjectID == NULL) ||
(ppszBulkPropertiesContext == NULL))
{
hr = E_POINTER;
CHECK_HR(hr, "Cannot have NULL parameter");
return hr;
}
*ppszBulkPropertiesContext = NULL;
hr = CoCreateInstance(CLSID_PortableDevicePropVariantCollection,
NULL,
CLSCTX_INPROC_SERVER,
IID_IPortableDevicePropVariantCollection,
(VOID**) &pObjectIDs);
CHECK_HR(hr, "Failed to CoCreate CLSID_IPortableDevicePropVariantCollection");
if (hr == S_OK)
{
hr = m_pDevice->GetObjectIDsByFormat(Scope, guidObjectFormat, pszParentObjectID, dwDepth, pObjectIDs);
CHECK_HR(hr, "Faield to get list of object ids by format");
}
if (hr == S_OK)
{
pContext = new BulkPropertiesContext();
if(pContext == NULL)
{
hr = E_OUTOFMEMORY;
CHECK_HR(hr, "Failed to allocate new bulk properties context");
}
}
if (hr == S_OK)
{
pContext->Properties = pProperties;
pContext->ObjectIDs = pObjectIDs;
pContext->Scope = Scope;
hr = pContextMap->Add(pContext, strKey);
CHECK_HR(hr, "Failed to insert bulk property operation context into our context Map");
}
if (hr == S_OK)
{
*ppszBulkPropertiesContext = AtlAllocTaskWideString(strKey);
if (*ppszBulkPropertiesContext == NULL)
{
hr = E_OUTOFMEMORY;
CHECK_HR(hr, "Failed to allocate bulk properties context");
}
}
SAFE_RELEASE(pContext);
return hr;
}
示例14: CopyComPointer
HRESULT Scheduler::StartScheduler(IMFClock *pClock)
{
if (m_hSchedulerThread != NULL)
{
return E_UNEXPECTED;
}
HRESULT hr = S_OK;
DWORD dwID = 0;
CopyComPointer(m_pClock, pClock);
// Set a high the timer resolution (ie, short timer period).
timeBeginPeriod(1);
// Create an event to wait for the thread to start.
m_hThreadReadyEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (m_hThreadReadyEvent == NULL)
{
CHECK_HR(hr = HRESULT_FROM_WIN32(GetLastError()));
}
// Create an event to wait for flush commands to complete.
m_hFlushEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (m_hFlushEvent == NULL)
{
CHECK_HR(hr = HRESULT_FROM_WIN32(GetLastError()));
}
// Create the scheduler thread.
m_hSchedulerThread = CreateThread(NULL, 0, SchedulerThreadProc, (LPVOID)this, 0, &dwID);
if (m_hSchedulerThread == NULL)
{
CHECK_HR(hr = HRESULT_FROM_WIN32(GetLastError()));
}
HANDLE hObjects[] = { m_hThreadReadyEvent, m_hSchedulerThread };
DWORD dwWait = 0;
// Wait for the thread to signal the "thread ready" event.
dwWait = WaitForMultipleObjects(2, hObjects, FALSE, INFINITE); // Wait for EITHER of these handles.
if (WAIT_OBJECT_0 != dwWait)
{
// The thread terminated early for some reason. This is an error condition.
CloseHandle(m_hSchedulerThread);
m_hSchedulerThread = NULL;
CHECK_HR(hr = E_UNEXPECTED);
}
m_dwThreadID = dwID;
done:
// Regardless success/failure, we are done using the "thread ready" event.
if (m_hThreadReadyEvent)
{
CloseHandle(m_hThreadReadyEvent);
m_hThreadReadyEvent = NULL;
}
return hr;
}
示例15: CHECK_HR
HRESULT WpdObjectProperties::DispatchWpdMessage(const PROPERTYKEY& Command,
IPortableDeviceValues* pParams,
IPortableDeviceValues* pResults)
{
HRESULT hr = S_OK;
if (hr == S_OK)
{
if (Command.fmtid != WPD_CATEGORY_OBJECT_PROPERTIES)
{
hr = E_INVALIDARG;
CHECK_HR(hr, "This object does not support this command category %ws",CComBSTR(Command.fmtid));
}
}
if (hr == S_OK)
{
if (IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_GET_SUPPORTED))
{
hr = OnGetSupportedProperties(pParams, pResults);
CHECK_HR(hr, "Failed to get supported properties");
}
else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_GET))
{
hr = OnGetValues(pParams, pResults);
if(FAILED(hr))
{
CHECK_HR(hr, "Failed to read properties");
}
}
else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_GET_ALL))
{
hr = OnGetAllValues(pParams, pResults);
if(FAILED(hr))
{
CHECK_HR(hr, "Failed to read all properties");
}
}
else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_SET))
{
hr = OnWriteProperties(pParams, pResults);
if(FAILED(hr))
{
CHECK_HR(hr, "Failed to write properties");
}
}
else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_GET_ATTRIBUTES))
{
hr = OnGetAttributes(pParams, pResults);
if(FAILED(hr))
{
CHECK_HR(hr, "Failed to get property attributes");
}
}
else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_DELETE))
{
hr = OnDelete(pParams, pResults);
if(FAILED(hr))
{
CHECK_HR(hr, "Failed to delete properties");
}
}
else
{
hr = E_NOTIMPL;
CHECK_HR(hr, "This object does not support this command id %d", Command.pid);
}
}
return hr;
}