DirectX enumeration system devices

Source: Internet
Author: User
Void csysenumdlg: displayfullcategoryset (void)
{
Uses_conversion;


Hresult hr;
Ienummoniker * pemcat = 0;
Icreatedevenum * pcreatedevenum = NULL;
Int nclasses = 0;


// Create an enumerator
HR = cocreateinstance (clsid_systemdeviceenum, null, clsctx_inproc_server,
Iid_icreatedevenum, (void **) & pcreatedevenum );
Assert (succeeded (HR ));
If (failed (HR ))
Return;


// Use the meta-category that contains a list of all categories.
// This emulates the behavior of graphedit.
HR = pcreatedevenum-> createclassenumerator (
Clsid_activemoviecategories, & pemcat, 0 );
Assert (succeeded (HR ));


If (hR = s_ OK)
{
Imoniker * pmcat;
Ulong cfetched;


// Enumerate over every category
While (hR = pemcat-> next (1, & pmcat, & cfetched ),
HR = s_ OK)
{
Ipropertybag * ppropbag;


// Associate moniker with a file
HR = pmcat-> bindtostorage (0, 0, iid_ipropertybag, (void **) & ppropbag );
If (succeeded (HR ))
{
Variant varcatclsid;
Varcatclsid. Vt = vt_bstr;


// Read CLSID string from property bag
HR = ppropbag-> Read (L "CLSID", & varcatclsid, 0 );
If (succeeded (HR ))
{
CLSID clsidcat; // enumerate all device classes


If (clsidfromstring (varcatclsid. bstrval, & clsidcat) = s_ OK)
{
// Use the guid if we can't get the name
Wchar * wszcatname;
Tchar szcatdesc [max_path];


Variant varcatname;
Varcatname. Vt = vt_bstr;


// Read Filter Name
HR = ppropbag-> Read (L "friendlyname", & varcatname, 0 );
If (succeeded (HR ))
Wszcatname = varcatname. bstrval;
Else
Wszcatname = varcatclsid. bstrval;


# Ifndef Unicode
Widechartomultibyte (
Cp_acp, 0, wszcatname,-1,
Szcatdesc, sizeof (szcatdesc), 0, 0 );
# Else
Lstrcpy (szcatdesc, w2t (wszcatname ));
# Endif


If (succeeded (HR ))
Sysfreestring (varcatname. bstrval );


// Add category name and CLSID to list box
Addfiltercategory (szcatdesc, & clsidcat );
Nclasses ++;
}


Sysfreestring (varcatclsid. bstrval );
}


Ppropbag-> release ();
}
Else
{
Break;
}


Pmcat-> release ();
} // For Loop


Pemcat-> release ();
}


Pcreatedevenum-> release ();


// Update ListBox title with number of classes
Setnumclasses (nclasses );
}

DirectX enumeration system devices

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.