简体   繁体   中英

ICreateDevEnum works ok 32bit but fails on 64bit

I have a strange problem and I've convinced that's it's something silly that I'm doing, or most likely, not doing.

I'm using 'Studio 2010 Pro on an x64 machine using Win7 Ultimate and the WinSDK (x64) 7.1 to develop a DirectShow app ( for the record I've also tried WinSDK7.0 and 7.0A ). My concern and issue comes with creating an enumerator to enumerate for capture devices, specifically using CLSID_VideoInputDeviceCategory. I've searched high and low and only found similar problems when people are developing their own filters and the filter isn't registered correctly.

However, I can't for life of me figure out what's causing this....

The following most basic example code succeeds ok with a 32bit x86 build, but changing to build for x64 and it fails at the

hr = CoCreateInstance(CLSID_VideoInputDeviceCategory,nullptr,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&pCreateDevEnum));

with a '0x80040154 Class not registered' error.

Any help or pointers would be greatly appreciated.

Many thanks

An extract of the source that works on x86 and not on x64...

#include <Windows.h>
#include <dshow.h>

INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev,LPSTR lpCmdLine,INT iCmdShow){
    ICreateDevEnum* pCreateDevEnum = nullptr;
    IEnumMoniker* pEnumMoniker = nullptr;
    HRESULT hr = S_OK;

    CoInitializeEx(nullptr,COINIT_MULTITHREADED);

    hr = CoCreateInstance(CLSID_VideoInputDeviceCategory,nullptr,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&pCreateDevEnum));

    if(FAILED(hr)){
    [...more code is omitted as its not needed to show it]

Categories are not COM-creatable. Those are GUIDs to identify/list categories of certain classes, and CoCreateInstance works with CLSID - identifiers of COM classes.

Correct usage is via System Device Enumerator . See also:

// Create the System Device Enumerator.
ICreateDevEnum *pDevEnum;
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL,  
    CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pDevEnum));

if (SUCCEEDED(hr))
{
    // Create an enumerator for the category.
    hr = pDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, 
        ppEnum, 0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM