Help - Search - Members - Calendar
Full Version: GetDisplayName not working properly
DVB Owners Discussion Forum - dvbowners.com > Technical & Development Forums > BDA Driver Development
nate
I've started looking at how to uniquely identify cards so i can make it possible to select which cards to use and i figured the string returned IMoniker::GetDisplayName would do the job nicely. The only problem is i can't get it to return the full string.
CODE
HRESULT hr = S_OK;
CComPtr <IEnumMoniker> pEnum;
CComPtr <ICreateDevEnum> pSysDevEnum;
CComPtr <IMoniker> pMoniker;

hr = pSysDevEnum.CoCreateInstance(CLSID_SystemDeviceEnum)

hr = pSysDevEnum->CreateClassEnumerator(clsidDeviceClass, &pEnum, 0);

while(pEnum->Next(1, &pMoniker, 0) == S_OK)
{
    LPOLESTR pStr;
    IBindCtx *pBindCtx;
    hr = CreateBindCtx(0, &pBindCtx);

    hr = pMoniker->GetDisplayName(pBindCtx, NULL, &pStr);

    pMoniker.Release();
}
pEnum.Release();
pSysDevEnum.Release();


graphedt.exe shows the full string in the insert filter dialog but when i run this code pStr always comes out with the end chopped off.
@device:pnp:\\?\pci#ven_109e&dev_036e&subsys_00011822&rev_11#3&61aaa01&0&40#{71985f48-1ca1-11d3-9cc8-00c04f7971e0}\{4e603

Has anyone else done this and had the same problem? or can you point out what i'm doing wrong?
Spectrum
I don't actually know, but a google search came up with this code sample http://www.alexfedotov.com/samples/enumrot.asp.

Spectrum
JoeyBloggs
Seems to work ok for me ~

alternatively, you could use piPropertyBag->Read(L"DevicePath", &varName, 0);


CODE
USES_CONVERSION;

HRESULT hr = S_OK;

IBindCtx*      piBindCtx           = NULL;
IMoniker*      piMoniker           = NULL;
IPropertyBag*  piPropertyBag       = NULL;

LPOLESTR       pszDisplayName      = NULL;

CString        sMonikerDisplayName = _T("");

hr = ::CreateBindCtx(NULL, &piBindCtx);

if (SUCCEEDED(hr))
{
    hr = piMoniker->GetDisplayName(piBindCtx, NULL, &pszDisplayName);

    sMonikerDisplayName = OLE2T(pszDisplayName);

    CoTaskMemFree(pszDisplayName);

    //////////////

    hr = piMoniker->BindToStorage(0, 0, IID_IPropertyBag, reinterpret_cast<void**>(&piPropertyBag) );
    
    if (SUCCEEDED(hr))
    {
 CString sFriendlyName = _T("");
 CString sDescription  = _T("");
 CString sDevicePath   = _T("");

 // To retrieve the filter's friendly name, do the following:
 VARIANT varName;
 VariantInit(&varName);

 hr = piPropertyBag->Read(L"FriendlyName", &varName, 0);
 
 if (SUCCEEDED(hr))
 {
     sFriendlyName = varName.bstrVal; // O2T conversion
 }
 
 VariantClear(&varName);

 hr = piPropertyBag->Read(L"Description", &varName, 0);
 
 if (SUCCEEDED(hr))
 {
     sDescription = varName.bstrVal; // O2T conversion
 }
 
 VariantClear(&varName);

 hr = piPropertyBag->Read(L"DevicePath", &varName, 0);
 
 if (SUCCEEDED(hr))
 {
     sDevicePath = varName.bstrVal; // O2T conversion
 }
 
 VariantClear(&varName);


 MYTRACE("Found %s %s %s\n", sMonikerDeviceClass, sFriendlyName, sDevicePath);
 MYTRACE("DisplayName = %s\n", sMonikerDisplayName);

 piPropertyBag->Release();
    }
}

piBindCtx->Release();
nate
Thanks Joey, i'll give it a try, but i have to ask, how did you find out what the names were for the IPropertyBag Reads?

I spent a couple of hours searching trying to find a list of values and the only thing i came up with was using the IPropertyBag2 interface to get the list, only when i tried it i found that the IPropertyBag2 interface wasn't supported by the IMonker for the tuner.
JoeyBloggs
Yup I went down the same path with IPropertyBag2 sad.gif

I don't really remember where I found the property names probably from here ~ http://msdn.microsoft.com/archive/default....pturedevice.asp
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-2008 Invision Power Services, Inc.