the following code
IWiaDevMgr2 * pWiaDevMgr=NULL;
Retrieves the hr=CoCreateInstance (CLSID_WiaDevMgr2, NULL, CLSCTX_LOCAL_SERVER IID_IWiaDevMgr2, (PVOID *) & amp; PWiaDevMgr);
If (pWiaDevMgr)
{
BSTR * pbstrDeviceID=NULL;
IWiaItem2 * ppItemRoot=NULL;
Hr=pWiaDevMgr - & gt; SelectDeviceDlg (NULL, STI_DEVICE_MJ_TYPE: : StiDeviceTypeScanner, 0, pbstrDeviceID, & amp; PpItemRoot);
If (SUCCEEDED (hr))
{
LONG num=0;
BSTR * pbstrFilePaths=0;
IWiaItem2 * pWiaItems=0;
BSTR bstr1=_T (" Test ");
BSTR bstr2=_T (" \ ");
HWND hh=GetSafeHwnd ();
Hr=ppItemRoot - & gt; DeviceDlg (0, hh, bstr1 bstr2, & amp; Num, & amp; PbstrFilePaths, & amp; PWiaItems);
}
}
The middle pWiaDevMgr - & gt; SelectDeviceDlg can open choose device interface, then the following ppItemRoot - & gt; DeviceDlg I think is directly open the figure in the interface, but this function always returns (E_INVALIDARG One or more arguments are invalid.), I don't know which parameters have a problem, consult with the bosses have not used this function inspiration, thank you
CodePudding user response:
BSTR bstr1=_T (" Test "); This is the wrongBSTR strings in the front of the buffer and the length of the four bytes, directly in c + + string how line
You can use CComBSTR (L "Test"); replace