From: cibz on
I am trying to do a wia scan using the IWiaDevMgr, IWiaItem and
IWiaDataTransfer

Created the IWiaDevMgr as in the following code
CComPtr<IWiaDevMgr> pWiaDevMgr
hr = pWiaDevMgr.CoCreateInstance(CLSID_WiaDevMgr);

then call the CreateDevice on that object with the correct device id
hr=pWiaDevMgr->CreateDevice(str,&pItemRoot);

and then i call DeviceDlg on the pItemRoot
CComPtrArray<IWiaItem> ppIWiaItem;
hr = pItemRoot->DeviceDlg(
hWndParent,
lFlags,
lIntent,
&ppIWiaItem.Count(),
&ppIWiaItem
);

make IWiaDataTransfer using the ppIWiaItem
CComQIPtr<IWiaDataTransfer> pIWiaDataTransfer(ppIWiaItem[i]);

and call idtGetBandedData to do the scanning
hr = pIWiaDataTransfer->idtGetBandedData(
&WiaDataTransferInfo,
pDataCallback
);
;

this code is working fine

But now i want to avoid the pItemRoot->DeviceDlg call (I dont want to
display the default UI)

How can I do that? please help
From: cibz on
I found it we can use the IEnumWiaItem got by calling EnumChildItems
and enumarete the correct chiled item

see http://msdn.microsoft.com/en-us/library/ms629858(VS.85).aspx for
the implementation of the TransferWiaItem

(need to fix some bugs in the microsoft sample :) and implement the
CWiaDataCallback if you need implementation plz mail me)

CComPtr<IEnumWiaItem> pppIEnumWiaItem;
hr=pItemRoot->EnumChildItems(&pppIEnumWiaItem);
if (SUCCEEDED(hr))
{
ULONG fetched=0;
ULONG celt=0;
CComPtr<IWiaItem> pppIWiaItem;
pppIEnumWiaItem->GetCount(&celt);
if(celt>0)
{
pppIEnumWiaItem->Next(1,&pppIWiaItem,&fetched);
if(fetched>0)
{
hr=TransferWiaItem(pppIWiaItem);
if (SUCCEEDED(hr))
return hr;
}
}
}