本文整理汇总了C++中IPropertyBag::Read方法的典型用法代码示例。如果您正苦于以下问题:C++ IPropertyBag::Read方法的具体用法?C++ IPropertyBag::Read怎么用?C++ IPropertyBag::Read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPropertyBag
的用法示例。
在下文中一共展示了IPropertyBag::Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindFilter
bool CDirectShowFilterFinder::FindFilter(const GUID *pInTypes,int InTypeCount,
const GUID *pOutTypes,int OutTypeCount,DWORD Merit)
{
// フィルタを検索する
bool bRet = false;
IFilterMapper2 *pMapper=NULL;
HRESULT hr=::CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC, IID_IFilterMapper2, (void **)&pMapper);
if (SUCCEEDED(hr)) {
IEnumMoniker *pEnum=NULL;
hr = pMapper->EnumMatchingFilters(
&pEnum,
0, // 予約済み
TRUE, // 完全一致を使用するか
Merit, // 最小のメリット
TRUE, // 1 つ以上の入力ピンか?
InTypeCount, // 入力のメジャータイプ/サブタイプの対の数
pInTypes, // 入力のメジャータイプ/サブタイプの対の配列
NULL, // 入力メディア
NULL, // 入力ピンのカテゴリ
FALSE, // レンダラでなければならないか
TRUE, // 1 つ以上の出力ピンか
OutTypeCount, // 出力のメジャータイプ/サブタイプの対の数
pOutTypes, // 出力のメジャータイプ/サブタイプの対の配列
NULL, // 出力メディア
NULL); // 出力ピンのカテゴリ
if (SUCCEEDED(hr)) {
IMoniker *pMoniker;
ULONG cFetched;
while (pEnum->Next(1, &pMoniker, &cFetched) == S_OK) {
IPropertyBag *pPropBag;
hr=pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag);
if (SUCCEEDED(hr)) {
VARIANT varName,varID;
::VariantInit(&varName);
::VariantInit(&varID);
hr=pPropBag->Read(L"FriendlyName", &varName, 0);
if (SUCCEEDED(hr)) {
hr=pPropBag->Read(L"CLSID", &varID, 0);
if (SUCCEEDED(hr)) {
bRet = true;
CFilterInfo FilterInfo;
FilterInfo.SetFriendlyName(varName.bstrVal);
::CLSIDFromString(varID.bstrVal,&FilterInfo.m_clsid);
m_FilterList.push_back(FilterInfo);
::SysFreeString(varID.bstrVal);
}
SysFreeString(varName.bstrVal);
}
pPropBag->Release();
}
pMoniker->Release();
}
pEnum->Release();
}
pMapper->Release();
}
return bRet;
}
示例2: LogDeviceInformation
void Audio::LogDeviceInformation(IEnumMoniker *pEnum)
{
logger.addline("Starting to record audio or video input devices.", info);
IMoniker *pMoniker = NULL;
while (pEnum->Next(1, &pMoniker, NULL) == S_OK)
{
logger.addline("Have found a new device", success);
IPropertyBag *pPropBag;
HRESULT hr = pMoniker->BindToStorage(0, 0, IID_PPV_ARGS(&pPropBag));
if (FAILED(hr))
{
pMoniker->Release();
continue;
}
VARIANT var;
VariantInit(&var);
// Get description or friendly name.
hr = pPropBag->Read(L"Description", &var, 0);
if (FAILED(hr))
{
hr = pPropBag->Read(L"FriendlyName", &var, 0);
}
if (SUCCEEDED(hr))
{
//printf("%S\n", var.bstrVal);
logger.addline("Below is the device name.", debug);
logger.addline(ConvertBSTRToMBS(var.bstrVal), debug);
VariantClear(&var);
}
hr = pPropBag->Write(L"FriendlyName", &var);
// WaveInID applies only to audio capture devices.
hr = pPropBag->Read(L"WaveInID", &var, 0);
if (SUCCEEDED(hr))
{
//printf("WaveIn ID: %d\n", var.lVal);
logger.addline("Below is the WaveIn ID.", debug);
logger.addline("BLANK FOR NOW! FIX ME LATER", debug);
VariantClear(&var);
}
hr = pPropBag->Read(L"DevicePath", &var, 0);
if (SUCCEEDED(hr))
{
// The device path is not intended for display.
printf("Device path: %S\n", var.bstrVal);
logger.addline("Below is the device path.", debug);
//logger.addline(ConvertBSTRToMBS(var.bstrVal), success);
VariantClear(&var);
}
pPropBag->Release();
pMoniker->Release();
}
}
示例3: EnumDevices
int Camera::EnumDevices(PENUMDEVICE pCallback, void* pItem)
{
int nDevice = 0;
HRESULT hr = S_OK;
// System device enumerators
ICreateDevEnum *pDevEnum = NULL;
IEnumMoniker *pEnum = NULL;
IMoniker *pMoniker = NULL;
CoInitialize(NULL);
// Create system device enumerator
hr = CoCreateInstance( CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, reinterpret_cast<void**>(&pDevEnum) );
if (FAILED(hr)) {
return 0;
}
// create enumerator for video capture devices
hr = pDevEnum->CreateClassEnumerator( CLSID_VideoInputDeviceCategory, &pEnum, 0 );
if (SUCCEEDED(hr))
{
IBindCtx* pbcfull = NULL;
// Enumerate through the devices and print friendly name
while ( (pEnum->Next( 1, &pMoniker, NULL ) == S_OK))
{
VARIANT var;
IPropertyBag *pPropertyBag;
char szCameraName[200];
// FrienlyName : The name of the device
var.vt = VT_BSTR;
// Bind to IPropertyBag
pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropertyBag);
// Reference: https://msdn.microsoft.com/en-us/library/windows/desktop/dd377566(v=vs.85).aspx
hr = pPropertyBag->Read(L"Description", &var, 0); // "FriendlyName", "DevicePath", "Description"
if (FAILED(hr))
{
pPropertyBag->Read(L"FriendlyName", &var, 0);
}
WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1,szCameraName, sizeof(szCameraName), 0, 0);
if (pCallback != NULL) {
(*pCallback)(pItem, szCameraName);
}
VariantClear(&var);
// Release resource
pPropertyBag->Release();
nDevice++;
SAFE_RELEASE( pMoniker );
}
}
return nDevice; // returns count of camera
}
示例4: temp
QT_BEGIN_NAMESPACE
DSVideoDeviceControl::DSVideoDeviceControl(QObject *parent)
: QVideoDeviceControl(parent)
{
m_session = qobject_cast<DSCameraSession*>(parent);
devices.clear();
descriptions.clear();
CoInitialize(NULL);
ICreateDevEnum* pDevEnum = NULL;
IEnumMoniker* pEnum = NULL;
// Create the System device enumerator
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL,
CLSCTX_INPROC_SERVER, IID_ICreateDevEnum,
reinterpret_cast<void**>(&pDevEnum));
if(SUCCEEDED(hr)) {
// Create the enumerator for the video capture category
hr = pDevEnum->CreateClassEnumerator(
CLSID_VideoInputDeviceCategory, &pEnum, 0);
if (S_OK == hr) {
pEnum->Reset();
// go through and find all video capture devices
IMoniker* pMoniker = NULL;
while(pEnum->Next(1, &pMoniker, NULL) == S_OK) {
IPropertyBag *pPropBag;
hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag,
(void**)(&pPropBag));
if(FAILED(hr)) {
pMoniker->Release();
continue; // skip this one
}
// Find the description
WCHAR str[120];
VARIANT varName;
varName.vt = VT_BSTR;
hr = pPropBag->Read(L"FriendlyName", &varName, 0);
if(SUCCEEDED(hr)) {
wcsncpy(str, varName.bstrVal, sizeof(str)/sizeof(str[0]));
QString temp(QString::fromUtf16((unsigned short*)str));
devices.append(QString("ds:%1").arg(temp).toLocal8Bit().constData());
hr = pPropBag->Read(L"Description", &varName, 0);
wcsncpy(str, varName.bstrVal, sizeof(str)/sizeof(str[0]));
QString temp2(QString::fromUtf16((unsigned short*)str));
descriptions.append(temp2.toLocal8Bit().constData());
}
pPropBag->Release();
pMoniker->Release();
}
pEnum->Release();
}
pDevEnum->Release();
}
CoUninitialize();
selected = 0;
}
示例5: DisplayDeviceInformation
void DisplayDeviceInformation(IEnumMoniker *pEnum)
{
IMoniker *pMoniker = NULL;
while (pEnum->Next(1, &pMoniker, NULL) == S_OK)
{
IPropertyBag *pPropBag;
HRESULT hr = pMoniker->BindToStorage(0, 0, IID_PPV_ARGS(&pPropBag));
if (FAILED(hr))
{
pMoniker->Release();
continue;
}
VARIANT var;
VariantInit(&var);
// Get description or friendly name.
hr = pPropBag->Read(L"Description", &var, 0);
if (FAILED(hr))
{
hr = pPropBag->Read(L"FriendlyName", &var, 0);
}
if (SUCCEEDED(hr))
{
out_message() << "Capture device: " << var.bstrVal << std::endl;
VariantClear(&var);
}
hr = pPropBag->Write(L"FriendlyName", &var);
// WaveInID applies only to audio capture devices.
hr = pPropBag->Read(L"WaveInID", &var, 0);
if (SUCCEEDED(hr))
{
out_message() << "Audio device: " << var.lVal << std::endl;
VariantClear(&var);
}
hr = pPropBag->Read(L"DevicePath", &var, 0);
if (SUCCEEDED(hr))
{
// The device path is not intended for display.
out_message() << "Video device: " << var.bstrVal << std::endl;
VariantClear(&var);
}
pPropBag->Release();
pMoniker->Release();
}
}
示例6: DumpsDeviceProperty
void CObexPush::DumpsDeviceProperty(size_t DeviceIdx){
ObexDeviceList_t::iterator ItDevice = _LstDevice.begin();
std::advance(ItDevice, DeviceIdx);
IPropertyBag *pDeviceBag = NULL;
if (SUCCEEDED((*ItDevice)->EnumProperties(IID_IPropertyBag, (LPVOID *) & pDeviceBag))) {
VARIANT var;
VariantInit (&var);
if (SUCCEEDED(pDeviceBag->Read(_T("Name"), &var, NULL))) {
StartupStore(_T("..Obex Device <%d> Name : %s%s"), DeviceIdx, var.bstrVal, NEWLINE);
}
VariantClear(&var);
if (SUCCEEDED(pDeviceBag->Read(_T("Address"), &var, NULL))) {
if (var.vt == VT_BSTR)
StartupStore(_T("..Obex Device <%d> Adress : %s%s"), DeviceIdx, var.bstrVal, NEWLINE);
else if (var.vt == VT_I4)
StartupStore(_T("..Obex Device <%d> Adress : %08x%s"), DeviceIdx, var.ulVal, NEWLINE);
}
VariantClear(&var);
if (SUCCEEDED(pDeviceBag->Read(_T("Port"), &var, NULL))) {
if (var.vt == VT_BSTR)
StartupStore(_T("..Obex Device <%d> Port : %s%s"), DeviceIdx, var.bstrVal, NEWLINE);
else if (var.vt == VT_I4)
StartupStore(_T("..Obex Device <%d> Port : %08x%s"), DeviceIdx, var.ulVal, NEWLINE);
}
VariantClear(&var);
if (SUCCEEDED(pDeviceBag->Read(_T("Transport"), &var, NULL))) {
if (var.vt == VT_BSTR) {
StartupStore(_T("..Obex Device <%d> Transport : %s%s"), DeviceIdx, var.bstrVal, NEWLINE);
}
}
VariantClear(&var);
if (SUCCEEDED(pDeviceBag->Read (TEXT("ServiceUUID"), &var, NULL))) {
if (var.vt == VT_BSTR) {
// OBEXObjectPushServiceClass_UUID: TGUID = '{00001105-0000-1000-8000-00805F9B34FB}';
// OBEXFileTransferServiceClass_UUID: TGUID = '{00001106-0000-1000-8000-00805F9B34FB}';
StartupStore(_T("..Obex Device <%d> ServiceUUID : %s%s"), DeviceIdx, var.bstrVal, NEWLINE);
}
}
VariantClear(&var);
pDeviceBag->Release();
}
}
示例7: FindCaptureDevice
HRESULT VideoCapture::FindCaptureDevice(const wchar_t* deviceName, IBaseFilter** ppSrcFilter)
{
ICreateDevEnum *pSysDevEnum = NULL;
hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
IID_ICreateDevEnum, (void **)&pSysDevEnum);
if (FAILED(hr))
return hr;
// Obtain a class enumerator for the video input devices category.
IEnumMoniker *pEnumCat = NULL;
hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0);
if (hr == S_OK) {
// Enumerate the monikers.
IMoniker *pMoniker = NULL;
ULONG cFetched;
while (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) {
IPropertyBag *pPropBag;
hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag,
(void **)&pPropBag);
if (SUCCEEDED(hr)) {
// To retrieve the filter's friendly name
VARIANT varName;
VariantInit(&varName);
hr = pPropBag->Read(L"FriendlyName", &varName, 0);
if (SUCCEEDED(hr)) {
if (wcscmp(deviceName, varName.bstrVal) == 0) {
m_DeviceName = varName.bstrVal;
VariantClear(&varName);
IBaseFilter* pFilter;
hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter,
(void**)&pFilter);
if (SUCCEEDED(hr)) {
*ppSrcFilter = pFilter;
(*ppSrcFilter)->AddRef();
pFilter->Release();
}
pPropBag->Release();
pMoniker->Release();
pEnumCat->Release();
pSysDevEnum->Release();
return hr;
}
}
VariantClear(&varName);
pPropBag->Release();
}
pMoniker->Release();
}
pEnumCat->Release();
}
else {
pSysDevEnum->Release();
return hr;
}
pSysDevEnum->Release();
return -1;
}
示例8: GetDSFiltersNames
//Возвращает массив имен зарегистрированных в системе фильтров DirectShow (определенной категории)
//Что бы узнать требуемую размерность массива, достаточно вызвать функцию
//с lpwDSFilArr равным NULL - значение вернется в pArrSize.
//В случае ошибки функция вернет значение меньше нуля
int CDirectShow::GetDSFiltersNames(LPWSTR *lpwDSFilArr, LPDWORD pArrSize, DWORD dwBuffSize)
{
if (!m_lDSFilCount) return -1;
if (lpwDSFilArr)
{
IPropertyBag *pPropBag = NULL;
VARIANT varDSFName = { 0 };
varDSFName.vt = VT_BSTR;
for (m_lCounter = 0; m_lCounter < m_lDSFilCount; m_lCounter++)
{
if (m_pDSFMoniker[m_lCounter] == NULL) return -1;
m_pDSFMoniker[m_lCounter]->BindToStorage(NULL, NULL, IID_IPropertyBag, (LPVOID *)&pPropBag);
if (SUCCEEDED(pPropBag->Read(L"FriendlyName", &varDSFName, NULL)))
{
wcscpy(lpwDSFilArr[m_lCounter], varDSFName.bstrVal);
SysFreeString(varDSFName.bstrVal);
}
else
{
wcscpy(lpwDSFilArr[m_lCounter], L"<untitled>");
}
pPropBag->Release();
}
return 0;
}
else
{
*pArrSize = m_lDSFilCount;
return 0;
}
}
示例9: EnumDevices
int CCaptureVideo::EnumDevices(CArray<CString, CString>& arList)
{
int nCount = 0;
//枚举视频扑捉设备
ICreateDevEnum *pCreateDevEnum;
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,IID_ICreateDevEnum, (void**)&pCreateDevEnum);
if (hr != NOERROR)return -1;
CComPtr<IEnumMoniker> pEm;
hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,&pEm, 0);
if (hr != NOERROR)return -1;
pEm->Reset();
ULONG cFetched;
IMoniker *pM;
while(hr = pEm->Next(1, &pM, &cFetched), hr==S_OK)
{
IPropertyBag *pBag;
hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
if(SUCCEEDED(hr))
{
VARIANT var;
var.vt = VT_BSTR;
hr = pBag->Read(L"FriendlyName", &var, NULL);
if (hr == NOERROR)
{
char szStr[2048];
nCount++;
WideCharToMultiByte(CP_ACP,0,var.bstrVal, -1, szStr, 2048, NULL, NULL);
arList.Add( CString(szStr) );
SysFreeString(var.bstrVal);
pM->AddRef();
}
pBag->Release();
}
pM->Release();
}
return nCount;
}
示例10: getFriendlyName
HRESULT CDSFilterEnum::getFriendlyName(wstring* pName)
{
if (m_pIMoniker == NULL) {
return E_POINTER;
}
IPropertyBag *pBag;
HRESULT hr =m_pIMoniker->BindToStorage(NULL, NULL, IID_IPropertyBag, reinterpret_cast<void**>(&pBag));
if(FAILED(hr)) {
OutputDebug(L"Cannot BindToStorage for.\n");
return hr;
}
VARIANT varName;
::VariantInit(&varName);
hr = pBag->Read(L"FriendlyName", &varName, NULL);
if(FAILED(hr)){
OutputDebug(L"IPropertyBag->Read method failed for.\n");
SAFE_RELEASE(pBag);
::VariantClear(&varName);
return hr;
}
*pName = varName.bstrVal;
SAFE_RELEASE(pBag);
::VariantClear(&varName);
return S_OK;
}
示例11: GetAudioDevices
HRESULT CaptureDevices::GetAudioDevices(vector<wstring> *audioDevices)
{
if (!enumMonikerAudio)
return E_FAIL;
IMoniker *pMoniker = NULL;
wstring name;
while (enumMonikerAudio->Next(1, &pMoniker, NULL) == S_OK)
{
IPropertyBag *pPropBag;
HRESULT hr = pMoniker->BindToStorage(0, 0, IID_PPV_ARGS(&pPropBag));
if (FAILED(hr))
{
pMoniker->Release();
continue;
}
VARIANT var;
VariantInit(&var);
hr = pPropBag->Read(L"FriendlyName", &var, 0);
if (SUCCEEDED(hr))
{
name = var.bstrVal;
VariantClear(&var);
}
pPropBag->Release();
pMoniker->Release();
if (!name.empty())
audioDevices->push_back(name);
}
}
示例12: BindFilter
bool CCaptureVideo::BindFilter(int deviceId, IBaseFilter **pFilter)
{
if (deviceId < 0) return false;
// enumerate all video capture devices
CComPtr<ICreateDevEnum> pCreateDevEnum;
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
IID_ICreateDevEnum, (void**)&pCreateDevEnum);
if (hr != NOERROR) return false;
CComPtr<IEnumMoniker> pEm;
hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,&pEm, 0);
if (hr != NOERROR) return false;
pEm->Reset();
ULONG cFetched;
IMoniker* pM;
int index = 0;
while(hr = pEm->Next(1, &pM, &cFetched), hr==S_OK, index <= deviceId)
{
IPropertyBag* pBag;
hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
if(SUCCEEDED(hr))
{
VARIANT var;
var.vt = VT_BSTR;
hr = pBag->Read(L"FriendlyName", &var, NULL);
if (hr == NOERROR)
{
if (index == deviceId)
{
pM->BindToObject(0, 0, IID_IBaseFilter, (void**)pFilter);
}
SysFreeString(var.bstrVal);
}
pBag->Release();
}
pM->Release();
index++;
}
return true;
}
示例13: GetCameraNameDX
void FaceTrackNoIR::GetCameraNameDX() {
#if defined(_WIN32)
ui.cameraName->setText("No video-capturing device was found in your system: check if it's connected!");
// Create the System Device Enumerator.
HRESULT hr;
ICreateDevEnum *pSysDevEnum = NULL;
hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum);
if (FAILED(hr))
{
qDebug() << "GetWDM says: CoCreateInstance Failed!";
return;
}
qDebug() << "GetWDM says: CoCreateInstance succeeded!";
// Obtain a class enumerator for the video compressor category.
IEnumMoniker *pEnumCat = NULL;
hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0);
if (hr == S_OK) {
qDebug() << "GetWDM says: CreateClassEnumerator succeeded!";
IMoniker *pMoniker = NULL;
ULONG cFetched;
if (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) {
IPropertyBag *pPropBag;
hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag);
if (SUCCEEDED(hr)) {
VARIANT varName;
VariantInit(&varName);
hr = pPropBag->Read(L"FriendlyName", &varName, 0);
if (SUCCEEDED(hr))
{
QString str((QChar*)varName.bstrVal, wcslen(varName.bstrVal));
qDebug() << "GetWDM says: Moniker found:" << str;
ui.cameraName->setText(str);
}
VariantClear(&varName);
pPropBag->Release();
}
pMoniker->Release();
}
pEnumCat->Release();
}
pSysDevEnum->Release();
#else
for (int i = 0; i < 16; i++) {
char buf[128];
sprintf(buf, "/dev/video%d", i);
if (access(buf, R_OK | W_OK) == 0) {
ui.cameraName->setText(QString(buf));
break;
}
}
#endif
}
示例14: exceededDatabaseQuota
HRESULT STDMETHODCALLTYPE UIDelegate::exceededDatabaseQuota(
/* [in] */ IWebView *sender,
/* [in] */ IWebFrame *frame,
/* [in] */ IWebSecurityOrigin *origin,
/* [in] */ BSTR databaseIdentifier)
{
BSTR protocol;
BSTR host;
unsigned short port;
origin->protocol(&protocol);
origin->host(&host);
origin->port(&port);
if (!done && gTestRunner->dumpDatabaseCallbacks())
printf("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:{%S, %S, %i} database:%S\n", protocol, host, port, databaseIdentifier);
SysFreeString(protocol);
SysFreeString(host);
unsigned long long defaultQuota = 5 * 1024 * 1024;
double testDefaultQuota = gTestRunner->databaseDefaultQuota();
if (testDefaultQuota >= 0)
defaultQuota = testDefaultQuota;
COMPtr<IWebDatabaseManager> databaseManager;
COMPtr<IWebDatabaseManager> tmpDatabaseManager;
if (FAILED(WebKitCreateInstance(CLSID_WebDatabaseManager, 0, IID_IWebDatabaseManager, (void**)&tmpDatabaseManager))) {
origin->setQuota(defaultQuota);
return S_OK;
}
if (FAILED(tmpDatabaseManager->sharedWebDatabaseManager(&databaseManager))) {
origin->setQuota(defaultQuota);
return S_OK;
}
IPropertyBag* detailsBag;
if (FAILED(databaseManager->detailsForDatabase(databaseIdentifier, origin, &detailsBag))) {
origin->setQuota(defaultQuota);
return S_OK;
}
VARIANT var;
detailsBag->Read(WebDatabaseUsageKey, &var, 0);
unsigned long long expectedSize = V_UI8(&var);
unsigned long long newQuota = defaultQuota;
double maxQuota = gTestRunner->databaseMaxQuota();
if (maxQuota >= 0) {
if (defaultQuota < expectedSize && expectedSize <= maxQuota) {
newQuota = expectedSize;
printf("UI DELEGATE DATABASE CALLBACK: increased quota to %llu\n", newQuota);
}
}
origin->setQuota(newQuota);
return S_OK;
}
示例15: EnumDevices
int VideoCapture::EnumDevices()
{
int id = 0;
// enumerate all video capture devices
CComPtr<ICreateDevEnum> pCreateDevEnum;
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
IID_ICreateDevEnum, (void**)&pCreateDevEnum);
if (hr != NOERROR) return -1;
CComPtr<IEnumMoniker> pEm;
hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,
&pEm, 0);
if (hr != NOERROR) return -1 ;
pEm->Reset();
IMoniker *pM;
nDevices = 0;
while(hr = pEm->Next(1, &pM, NULL), hr==S_OK)
nDevices++;
if (nDevices==0) return -1;
pEm->Reset();
devices_names = new string[nDevices];
while(hr = pEm->Next(1, &pM, NULL), hr==S_OK)
{
IPropertyBag *pBag;
hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
if(SUCCEEDED(hr))
{
VARIANT var;
var.vt = VT_BSTR;
hr = pBag->Read(L"FriendlyName", &var, NULL);
if (hr == NOERROR)
{
TCHAR str[2048];
WideCharToMultiByte(CP_ACP,0,var.bstrVal, -1, str, 2048, NULL, NULL);
devices_names[id] = str;
id++;
SysFreeString(var.bstrVal);
}
pBag->Release();
}
pM->Release();
}
return id;
}