I found this tutorial on using WIA in c++, but I don't understand how to use it. The following doesn't succeed, and I don't what exactly is wrong here. Basically I copied the code from the tutorial.
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); 
}
By the way, I am using Windows 7 64-bit, so using IWiaDevMgr2 should be fine.
                        
That's 0x800401f0 when you interpret/display it as an unsigned number. As you should, HRESULT is not a signed type. From the WinError.h SDK file:
Add this line to your initialization code: