Question

J'ai trouvé ce tutoriel sur l'utilisation WIA en c ++, mais je ne comprends pas comment l'utiliser. Ce qui suit ne réussit pas, et je ne le font pas ce qui est faux ici exactement. Fondamentalement, je copiais le code du tutoriel.

void init() {
    IWiaDevMgr2* devMgr; 
    HRESULT hr = createWiaDeviceManager( &devMgr ); 

    if(!SUCCEEDED(hr))
    {
        std::cout << "couldn't create WIA Device Manager!\n"; 
        return; 
    }
   ...
}

HRESULT createWiaDeviceManager(IWiaDevMgr2** devMgr)
{
    if(devMgr == 0) return E_INVALIDARG; 

    *devMgr = 0; 

    return CoCreateInstance( CLSID_WiaDevMgr2, 0, CLSCTX_LOCAL_SERVER, IID_IWiaDevMgr2, (void**)devMgr); 
}

Par ailleurs, j'utilise Windows 7 64 bits, donc l'utilisation IWiaDevMgr2 devrait être bien.

Était-ce utile?

La solution

createWiaDeviceManager retourne toujours -2147221008

C'est 0x800401f0 lorsque vous interprétez / afficher comme un nombre non signé. Comme vous devriez, HRESULT est pas un type signé. A partir du fichier SDK Winerror.h:

//
// MessageId: CO_E_NOTINITIALIZED
//
// MessageText:
//
// CoInitialize has not been called.
//
#define CO_E_NOTINITIALIZED              _HRESULT_TYPEDEF_(0x800401F0L)

Ajoutez cette ligne à votre code d'initialisation:

CoInitialize(NULL);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top