Help - Search - Members - Calendar
Full Version: how to select connected bda devices in c++
DVB Owners Discussion Forum - dvbowners.com > Technical & Development Forums > BDA Driver Development
sele
Hello,

I want to display all connected bda devices (usb pci) but I have no idea and didnt found anything. Can anyone give me some keywords or a link or a little explanation. Thanks for helping.
Gobes
QUOTE (sele @ Dec 11 2007, 07:23 PM) *
Hello,

I want to display all connected bda devices (usb pci) but I have no idea and didnt found anything. Can anyone give me some keywords or a link or a little explanation. Thanks for helping.



Hi, this is the code which I have used to get the (PCI) BDA devices ( you can ignore the DevNum, and pDeviceItem params)

CODE

HRESULT __stdcall DVB_GetDeviceItem(int DevNum, DEVICE_ITEM *pDeviceItem)
{
HRESULT hr = S_OK;
BOOL fFoundFilter = FALSE;
CComPtr <IMoniker> pIMoniker;
CComPtr <IEnumMoniker> pIEnumMoniker;
CComPtr <ICreateDevEnum> pICreateDevEnum;

REFCLSID clsid = KSCATEGORY_BDA_NETWORK_TUNER;
unsigned char *temp = NULL;

if (!pICreateDevEnum)
{
hr = pICreateDevEnum.CoCreateInstance(CLSID_SystemDeviceEnum);
if (FAILED (hr))
{
//ErrorMessageBox(TEXT("LoadFilter(): Cannot CoCreate ICreateDevEnum"));
return (E_FAIL);
}
}
// obtain the enumerator
hr = pICreateDevEnum->CreateClassEnumerator(clsid, &pIEnumMoniker, 0);
// the call can return S_FALSE if no moniker exists, so explicitly check S_OK
if (FAILED (hr))
{
//ErrorMessageBox(TEXT("LoadFilter(): Cannot CreateClassEnumerator"));
return (E_FAIL);
}
if (S_OK != hr) // Class not found
{
//ErrorMessageBox(TEXT("LoadFilter(): Class not found, CreateClassEnumerator returned S_FALSE"));
return (E_FAIL);
}

short nCardIndex = -1 ;
// iterate until the searched index card will be found

do
{
nCardIndex ++;
pIMoniker = NULL;

} while((pIEnumMoniker->Next(1, &pIMoniker, 0) == S_OK) && nCardIndex != DevNum);


// ASSERT(pIMoniker);
if (pIMoniker == NULL)
return (E_POINTER);


// obtain filter's friendly name
CComPtr <IPropertyBag> pBag;

hr = pIMoniker->BindToStorage(
NULL,
NULL,
IID_IPropertyBag,
reinterpret_cast<void**>(&pBag)
);


if(FAILED(hr))
{
OutputDebugString (TEXT("LoadFilter(): Cannot BindToStorage"));
return (E_POINTER);
}

CComVariant varBSTR;
hr = pBag->Read(L"FriendlyName", &varBSTR, NULL);
if(FAILED(hr))
{
OutputDebugString (TEXT("LoadFilter(): IPropertyBag->Read method failed"));
pIMoniker = NULL;
return (E_POINTER);
//continue;
}


pDeviceItem->lCardIndex = nCardIndex ;
temp = (unsigned char*)&(pDeviceItem->deviceName);
WideCharToMultiByte(CP_ACP, 0, varBSTR.bstrVal, -1,(char *)temp, STRLEN_DEV_NAME, 0, 0);

pIMoniker = NULL;
return (S_OK);

}


I hope that will help you.
sele
Thanks Gobes,

your code really helped me. Thanks.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.