I'm following the sample from msdn https://msdn.microsoft.com/en-us/library/ms629848(v=vs.85).aspx:
HRESULT CreateWiaDeviceManager(IWiaDevMgr2 **ppWiaDevMgr)
{
CoInitialize(NULL);
// Validate arguments
if (NULL == ppWiaDevMgr)
return E_INVALIDARG;
// Initialize out variables
*ppWiaDevMgr = NULL;
// Create an instance of the device manager
HRESULT hr = CoCreateInstance( CLSID_WiaDevMgr2, NULL, CLSCTX_LOCAL_SERVER, IID_IWiaDevMgr2, (void**)ppWiaDevMgr );
// Return the result of creating the device manager
return hr;
}
But in compilation time I get this errors:
Error 389 error C2440: 'type cast' : cannot convert from 'const CLSID' to 'const IID *const '
Error 392 error C2440: 'type cast' : cannot convert from 'const IID' to 'const IID *const '
On the parameters of CoCreateInstance.
I didn't do any meaningful changes from the sample code... Can anyone suggest why I'm getting this?
Try
HRESULT hr = CoCreateInstance( &CLSID_WiaDevMgr2, NULL, &CLSCTX_LOCAL_SERVER, &IID_IWiaDevMgr2, (void**)ppWiaDevMgr );
In C++ the code builds as posted on MSVC2013, with includes:
#include <guiddef.h>
#include <afxwin.h>
#include <Wia.h>
#include <tchar.h>