Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2065 lines
92 KiB

  1. /**************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 2000
  4. *
  5. * TITLE: scanapi.cpp
  6. *
  7. * VERSION: 1.0
  8. *
  9. * DATE: 18 July, 2000
  10. *
  11. * DESCRIPTION:
  12. * Fake Scanner device library
  13. *
  14. ***************************************************************************/
  15. #include "pch.h"
  16. #ifdef UNICODE
  17. #define TSTRSTR wcsstr
  18. #define TSSCANF swscanf
  19. #else
  20. #define TSTRSTR strstr
  21. #define TSSCANF sscanf
  22. #endif
  23. #define MAX_CAPABILITIES 65535
  24. extern HINSTANCE g_hInst;
  25. ////////////////////////////////////////////////////////////////////////////////
  26. // MICRO DRIVER SYSTEM SUPPORT //
  27. ////////////////////////////////////////////////////////////////////////////////
  28. CMicroDriverAPI::CMicroDriverAPI()
  29. {
  30. // wipe supported resolutions string
  31. memset(m_szResolutions,0,sizeof(m_szResolutions));
  32. // wipe scaninfo structure
  33. memset(&m_ScanInfo,0,sizeof(m_ScanInfo));
  34. m_bDisconnected = FALSE;
  35. }
  36. CMicroDriverAPI::~CMicroDriverAPI()
  37. {
  38. //
  39. // close any open Device Data handles left open by Micro Driver
  40. // skip index 0 because WIAFBDRV owns that handle..
  41. //
  42. for(int i = 1; i < MAX_IO_HANDLES ; i++){
  43. if((NULL != m_ScanInfo.DeviceIOHandles[i]) && (INVALID_HANDLE_VALUE != m_ScanInfo.DeviceIOHandles[i])){
  44. CloseHandle(m_ScanInfo.DeviceIOHandles[i]);
  45. m_ScanInfo.DeviceIOHandles[i] = NULL;
  46. }
  47. }
  48. if(m_pMicroDriver){
  49. delete m_pMicroDriver;
  50. m_pMicroDriver = NULL;
  51. }
  52. }
  53. //
  54. // data acquisition functions
  55. //
  56. HRESULT CMicroDriverAPI::Scan(LONG lState, PBYTE pData, DWORD dwBytesToRead, PDWORD pdwBytesWritten)
  57. {
  58. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  59. WIALOG_NO_RESOURCE_ID,
  60. WIALOG_LEVEL1,
  61. "CMicroDriverAPI::Scan");
  62. HRESULT hr = S_OK;
  63. LONG lLine = SCAN_FIRST;
  64. switch (lState) {
  65. case SCAN_START:
  66. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("CMicroDriverAPI::Scan, SCAN_START"));
  67. lLine = SCAN_FIRST;
  68. break;
  69. case SCAN_CONTINUE:
  70. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("CMicroDriverAPI::Scan, SCAN_CONTINUE"));
  71. lLine = SCAN_NEXT;
  72. break;
  73. case SCAN_END:
  74. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("CMicroDriverAPI::Scan, SCAN_END"));
  75. lLine = SCAN_FINISHED;
  76. default:
  77. break;
  78. }
  79. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("CMicroDriverAPI::Scan, Requesting %d bytes from caller",dwBytesToRead));
  80. hr = m_pMicroDriver->Scan(&m_ScanInfo,lLine,pData,dwBytesToRead,(LONG*)pdwBytesWritten);
  81. if(pdwBytesWritten){
  82. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("CMicroDriverAPI::Scan, Returning %d bytes to caller",*pdwBytesWritten));
  83. } else {
  84. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("CMicroDriverAPI::Scan, Returning 0 bytes to caller"));
  85. }
  86. if(FAILED(hr)){
  87. WIAS_LERROR(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,("CMicroDriverAPI::Scan, Failed to Acquire data"));
  88. WIAS_LHRESULT(m_pIWiaLog, hr);
  89. } else {
  90. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("CMicroDriverAPI::Scan, Data Pointer = %x",pData));
  91. }
  92. //
  93. // handle device disconnection error
  94. //
  95. if(m_bDisconnected){
  96. WIAS_LERROR(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,("Scan, Device was disconnected, returning WIA_ERROR_OFFLINE to caller"));
  97. return WIA_ERROR_OFFLINE;
  98. }
  99. return hr;
  100. }
  101. HRESULT CMicroDriverAPI::SetDataType(LONG lDataType)
  102. {
  103. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  104. WIALOG_NO_RESOURCE_ID,
  105. WIALOG_LEVEL1,
  106. "CMicroDriverAPI::SetDataType");
  107. HRESULT hr = S_OK;
  108. VAL Val;
  109. memset(&Val,0,sizeof(Val));
  110. Val.pScanInfo = &m_ScanInfo;
  111. Val.lVal = lDataType;
  112. hr = m_pMicroDriver->MicroEntry(CMD_SETDATATYPE, &Val);
  113. return hr;
  114. }
  115. HRESULT CMicroDriverAPI::SetXYResolution(LONG lXResolution, LONG lYResolution)
  116. {
  117. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  118. WIALOG_NO_RESOURCE_ID,
  119. WIALOG_LEVEL1,
  120. "CMicroDriverAPI::SetXYResolution");
  121. HRESULT hr = S_OK;
  122. VAL Val;
  123. memset(&Val,0,sizeof(Val));
  124. Val.pScanInfo = &m_ScanInfo;
  125. Val.lVal = lXResolution;
  126. hr = m_pMicroDriver->MicroEntry(CMD_SETXRESOLUTION, &Val);
  127. if (FAILED(hr))
  128. return hr;
  129. Val.lVal = lYResolution;
  130. hr = m_pMicroDriver->MicroEntry(CMD_SETYRESOLUTION, &Val);
  131. return hr;
  132. }
  133. HRESULT CMicroDriverAPI::SetSelectionArea(LONG lXPos, LONG lYPos, LONG lXExt, LONG lYExt)
  134. {
  135. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  136. WIALOG_NO_RESOURCE_ID,
  137. WIALOG_LEVEL1,
  138. "CMicroDriverAPI::SetSelectionArea");
  139. HRESULT hr = S_OK;
  140. hr = m_pMicroDriver->SetPixelWindow(&m_ScanInfo,lXPos,lYPos,lXExt,lYExt);
  141. return hr;
  142. }
  143. HRESULT CMicroDriverAPI::SetContrast(LONG lContrast)
  144. {
  145. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  146. WIALOG_NO_RESOURCE_ID,
  147. WIALOG_LEVEL1,
  148. "CMicroDriverAPI::SetContrast");
  149. HRESULT hr = S_OK;
  150. VAL Val;
  151. memset(&Val,0,sizeof(Val));
  152. Val.pScanInfo = &m_ScanInfo;
  153. Val.lVal = lContrast;
  154. hr = m_pMicroDriver->MicroEntry(CMD_SETCONTRAST, &Val);
  155. return hr;
  156. }
  157. HRESULT CMicroDriverAPI::SetIntensity(LONG lIntensity)
  158. {
  159. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  160. WIALOG_NO_RESOURCE_ID,
  161. WIALOG_LEVEL1,
  162. "CMicroDriverAPI::SetIntensity");
  163. HRESULT hr = S_OK;
  164. VAL Val;
  165. memset(&Val,0,sizeof(Val));
  166. Val.pScanInfo = &m_ScanInfo;
  167. Val.lVal = lIntensity;
  168. hr = m_pMicroDriver->MicroEntry(CMD_SETINTENSITY, &Val);
  169. return hr;
  170. }
  171. HRESULT CMicroDriverAPI::DisableDevice()
  172. {
  173. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  174. WIALOG_NO_RESOURCE_ID,
  175. WIALOG_LEVEL1,
  176. "CMicroDriverAPI::DisableDevice");
  177. HRESULT hr = S_OK;
  178. m_bDisconnected = TRUE;
  179. return hr;
  180. }
  181. HRESULT CMicroDriverAPI::EnableDevice()
  182. {
  183. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  184. WIALOG_NO_RESOURCE_ID,
  185. WIALOG_LEVEL1,
  186. "CMicroDriverAPI::EnableDevice");
  187. HRESULT hr = S_OK;
  188. m_bDisconnected = FALSE;
  189. return hr;
  190. }
  191. HRESULT CMicroDriverAPI::DeviceOnline()
  192. {
  193. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  194. WIALOG_NO_RESOURCE_ID,
  195. WIALOG_LEVEL1,
  196. "CMicroDriverAPI::DeviceOnline");
  197. HRESULT hr = S_OK;
  198. VAL Val;
  199. memset(&Val,0,sizeof(Val));
  200. Val.pScanInfo = &m_ScanInfo;
  201. hr = m_pMicroDriver->MicroEntry(CMD_STI_GETSTATUS,&Val);
  202. if (SUCCEEDED(hr)) {
  203. if (Val.lVal != 1)
  204. hr = E_FAIL;
  205. }
  206. return hr;
  207. }
  208. HRESULT CMicroDriverAPI::GetDeviceEvent(GUID *pEvent)
  209. {
  210. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  211. WIALOG_NO_RESOURCE_ID,
  212. WIALOG_LEVEL1,
  213. "CMicroDriverAPI::GetDeviceEvent");
  214. HRESULT hr = S_OK;
  215. VAL Val;
  216. memset(&Val,0,sizeof(Val));
  217. Val.pScanInfo = &m_ScanInfo;
  218. *pEvent = GUID_NULL;
  219. hr = m_pMicroDriver->MicroEntry(CMD_STI_GETSTATUS,&Val);
  220. if (SUCCEEDED(hr)) {
  221. if (Val.pGuid != NULL)
  222. *pEvent = *Val.pGuid;
  223. else
  224. *pEvent = GUID_NULL;
  225. }
  226. return hr;
  227. }
  228. HRESULT CMicroDriverAPI::DoInterruptEventThread(PINTERRUPTEVENTINFO pEventInfo)
  229. {
  230. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  231. WIALOG_NO_RESOURCE_ID,
  232. WIALOG_LEVEL1,
  233. "CMicroDriverAPI::DoInterruptEventThread");
  234. HRESULT hr = S_OK;
  235. VAL Val;
  236. memset(&Val,0,sizeof(Val));
  237. Val.pHandle = pEventInfo->phSignalEvent;
  238. Val.handle = pEventInfo->hShutdownEvent;
  239. Val.pGuid = pEventInfo->pguidEvent;
  240. Val.pScanInfo = &m_ScanInfo;
  241. lstrcpyA(Val.szVal,pEventInfo->szDeviceName);
  242. hr = m_pMicroDriver->MicroEntry(CMD_GET_INTERRUPT_EVENT,&Val);
  243. return hr;
  244. }
  245. HRESULT CMicroDriverAPI::Diagnostic()
  246. {
  247. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  248. WIALOG_NO_RESOURCE_ID,
  249. WIALOG_LEVEL1,
  250. "CMicroDriverAPI::Diagnostic");
  251. HRESULT hr = S_OK;
  252. VAL Val;
  253. memset(&Val,0,sizeof(Val));
  254. Val.pScanInfo = &m_ScanInfo;
  255. hr = m_pMicroDriver->MicroEntry(CMD_STI_DIAGNOSTIC,&Val);
  256. return hr;
  257. }
  258. HRESULT CMicroDriverAPI::Initialize(PINITINFO pInitInfo)
  259. {
  260. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  261. WIALOG_NO_RESOURCE_ID,
  262. WIALOG_LEVEL1,
  263. "CMicroDriverAPI::Initialize");
  264. HRESULT hr = S_OK;
  265. VAL Val;
  266. memset(&Val,0,sizeof(Val));
  267. m_pMicroDriver = NULL;
  268. m_pMicroDriver = new CMICRO(pInitInfo->szModuleFileName);
  269. if (NULL != m_pMicroDriver) {
  270. // set DeviceIOHandles
  271. m_ScanInfo.DeviceIOHandles[0] = pInitInfo->hDeviceDataHandle;
  272. // send HKEY
  273. hr = SetSTIDeviceHKEY(&pInitInfo->hKEY);
  274. // send Initialize call
  275. Val.pScanInfo = &m_ScanInfo;
  276. lstrcpyA(Val.szVal,pInitInfo->szCreateFileName);
  277. hr = m_pMicroDriver->MicroEntry(CMD_INITIALIZE,&Val);
  278. if(hr == S_OK){
  279. //
  280. // perform a quick validation sweep, to make sure we didn't get bad values
  281. // from a micro driver
  282. //
  283. //
  284. // check current values, for strange negative values...or 0
  285. //
  286. if(m_ScanInfo.BedHeight <= 0){
  287. hr = E_INVALIDARG;
  288. }
  289. if(m_ScanInfo.BedWidth <= 0){
  290. hr = E_INVALIDARG;
  291. }
  292. if(m_ScanInfo.Xresolution <= 0){
  293. hr = E_INVALIDARG;
  294. }
  295. if(m_ScanInfo.Yresolution <= 0){
  296. hr = E_INVALIDARG;
  297. }
  298. if(m_ScanInfo.OpticalXResolution <= 0){
  299. hr = E_INVALIDARG;
  300. }
  301. if(m_ScanInfo.OpticalYResolution <= 0){
  302. hr = E_INVALIDARG;
  303. }
  304. if(SUCCEEDED(hr)){
  305. //
  306. // check logical values
  307. //
  308. }
  309. }
  310. } else
  311. hr = E_OUTOFMEMORY;
  312. return hr;
  313. }
  314. HRESULT CMicroDriverAPI::UnInitialize()
  315. {
  316. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  317. WIALOG_NO_RESOURCE_ID,
  318. WIALOG_LEVEL1,
  319. "CMicroDriverAPI::UnInitialize");
  320. HRESULT hr = S_OK;
  321. VAL Val;
  322. memset(&Val,0,sizeof(Val));
  323. // send UnInitialize call
  324. Val.pScanInfo = &m_ScanInfo;
  325. hr = m_pMicroDriver->MicroEntry(CMD_UNINITIALIZE,&Val);
  326. if(E_NOTIMPL == hr){
  327. hr = S_OK;
  328. }
  329. return hr;
  330. }
  331. //
  332. // standard device operations
  333. //
  334. HRESULT CMicroDriverAPI::ResetDevice()
  335. {
  336. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  337. WIALOG_NO_RESOURCE_ID,
  338. WIALOG_LEVEL1,
  339. "CMicroDriverAPI::ResetDevice");
  340. HRESULT hr = S_OK;
  341. VAL Val;
  342. memset(&Val,0,sizeof(Val));
  343. Val.pScanInfo = &m_ScanInfo;
  344. hr = m_pMicroDriver->MicroEntry(CMD_STI_DEVICERESET,&Val);
  345. return hr;
  346. }
  347. HRESULT CMicroDriverAPI::SetEmulationMode(LONG lDeviceMode)
  348. {
  349. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  350. WIALOG_NO_RESOURCE_ID,
  351. WIALOG_LEVEL1,
  352. "CMicroDriverAPI::SetEmulationMode");
  353. HRESULT hr = S_OK;
  354. return hr;
  355. }
  356. //
  357. // Automatic document feeder functions
  358. //
  359. HRESULT CMicroDriverAPI::ADFAttached()
  360. {
  361. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  362. WIALOG_NO_RESOURCE_ID,
  363. WIALOG_LEVEL1,
  364. "CMicroDriverAPI::ADFAttached");
  365. if(m_ScanInfo.ADF == 1)
  366. return S_OK;
  367. else
  368. return S_FALSE;
  369. }
  370. HRESULT CMicroDriverAPI::ADFHasPaper()
  371. {
  372. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  373. WIALOG_NO_RESOURCE_ID,
  374. WIALOG_LEVEL1,
  375. "CMicroDriverAPI::ADFHasPaper");
  376. HRESULT hr = S_OK;
  377. VAL Val;
  378. memset(&Val,0,sizeof(Val));
  379. Val.pScanInfo = &m_ScanInfo;
  380. Val.lVal = MCRO_ERROR_GENERAL_ERROR;
  381. hr = m_pMicroDriver->MicroEntry(CMD_GETADFHASPAPER,&Val);
  382. if(hr == E_NOTIMPL)
  383. return S_OK;
  384. if(FAILED(hr))
  385. return hr;
  386. if(MicroDriverErrorToWIAError(Val.lVal) == WIA_ERROR_PAPER_EMPTY){
  387. hr = S_FALSE;
  388. }
  389. return hr;
  390. }
  391. HRESULT CMicroDriverAPI::ADFAvailable()
  392. {
  393. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  394. WIALOG_NO_RESOURCE_ID,
  395. WIALOG_LEVEL1,
  396. "CMicroDriverAPI::ADFAvailable");
  397. HRESULT hr = S_OK;
  398. VAL Val;
  399. memset(&Val,0,sizeof(Val));
  400. Val.pScanInfo = &m_ScanInfo;
  401. Val.lVal = MCRO_ERROR_GENERAL_ERROR;
  402. hr = m_pMicroDriver->MicroEntry(CMD_GETADFAVAILABLE,&Val);
  403. if(hr == E_NOTIMPL)
  404. return S_OK;
  405. if(FAILED(hr))
  406. return hr;
  407. return MicroDriverErrorToWIAError(Val.lVal);
  408. }
  409. HRESULT CMicroDriverAPI::ADFFeedPage()
  410. {
  411. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  412. WIALOG_NO_RESOURCE_ID,
  413. WIALOG_LEVEL1,
  414. "CMicroDriverAPI::ADFFeedPage");
  415. HRESULT hr = S_OK;
  416. VAL Val;
  417. memset(&Val,0,sizeof(Val));
  418. Val.pScanInfo = &m_ScanInfo;
  419. Val.lVal = MCRO_ERROR_GENERAL_ERROR;
  420. hr = m_pMicroDriver->MicroEntry(CMD_LOAD_ADF,&Val);
  421. if(hr == E_NOTIMPL)
  422. return S_OK;
  423. if(FAILED(hr))
  424. return hr;
  425. return MicroDriverErrorToWIAError(Val.lVal);
  426. }
  427. HRESULT CMicroDriverAPI::ADFUnFeedPage()
  428. {
  429. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  430. WIALOG_NO_RESOURCE_ID,
  431. WIALOG_LEVEL1,
  432. "CMicroDriverAPI::ADFUnFeedPage");
  433. HRESULT hr = S_OK;
  434. VAL Val;
  435. memset(&Val,0,sizeof(Val));
  436. Val.pScanInfo = &m_ScanInfo;
  437. Val.lVal = MCRO_ERROR_GENERAL_ERROR;
  438. hr = m_pMicroDriver->MicroEntry(CMD_UNLOAD_ADF,&Val);
  439. if(hr == E_NOTIMPL)
  440. return S_OK;
  441. if(FAILED(hr))
  442. return hr;
  443. return MicroDriverErrorToWIAError(Val.lVal);
  444. }
  445. HRESULT CMicroDriverAPI::ADFStatus()
  446. {
  447. HRESULT hr = S_OK;
  448. VAL Val;
  449. memset(&Val,0,sizeof(Val));
  450. Val.pScanInfo = &m_ScanInfo;
  451. Val.lVal = MCRO_ERROR_GENERAL_ERROR;
  452. hr = m_pMicroDriver->MicroEntry(CMD_GETADFSTATUS,&Val);
  453. if(hr == E_NOTIMPL)
  454. return S_OK;
  455. if(FAILED(hr))
  456. return hr;
  457. return MicroDriverErrorToWIAError(Val.lVal);
  458. }
  459. HRESULT CMicroDriverAPI::SetFormat(GUID *pguidFormat)
  460. {
  461. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  462. WIALOG_NO_RESOURCE_ID,
  463. WIALOG_LEVEL1,
  464. "CMicroDriverAPI::SetFormat");
  465. HRESULT hr = S_OK;
  466. VAL Val;
  467. memset(&Val,0,sizeof(Val));
  468. Val.pScanInfo = &m_ScanInfo;
  469. Val.pGuid = pguidFormat;
  470. hr = m_pMicroDriver->MicroEntry(CMD_SETFORMAT,&Val);
  471. if(hr == E_NOTIMPL)
  472. return S_OK;
  473. if(FAILED(hr))
  474. return hr;
  475. return hr;
  476. }
  477. HRESULT CMicroDriverAPI::MicroDriverErrorToWIAError(LONG lMicroDriverError)
  478. {
  479. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  480. WIALOG_NO_RESOURCE_ID,
  481. WIALOG_LEVEL1,
  482. "CMicroDriverAPI::MicroDriverErrorToWIAError");
  483. HRESULT hr = E_FAIL;
  484. switch(lMicroDriverError){
  485. case MCRO_STATUS_OK:
  486. hr = S_OK;
  487. break;
  488. case MCRO_ERROR_USER_INTERVENTION:
  489. hr = WIA_ERROR_USER_INTERVENTION;
  490. break;
  491. case MCRO_ERROR_PAPER_JAM:
  492. hr = WIA_ERROR_PAPER_JAM;
  493. break;
  494. case MCRO_ERROR_PAPER_PROBLEM:
  495. hr = WIA_ERROR_PAPER_PROBLEM;
  496. break;
  497. case MCRO_ERROR_OFFLINE:
  498. hr = WIA_ERROR_OFFLINE;
  499. break;
  500. case MCRO_ERROR_GENERAL_ERROR:
  501. hr = WIA_ERROR_GENERAL_ERROR;
  502. break;
  503. case MCRO_ERROR_PAPER_EMPTY:
  504. hr = WIA_ERROR_PAPER_EMPTY;
  505. break;
  506. default:
  507. break;
  508. }
  509. return hr;
  510. }
  511. //
  512. // EXPECTED FORMAT:
  513. // Range: "MIN 75,MAX 1200,NOM 150,INC 1"
  514. // list: "75, 100, 150, 200, 600, 1200"
  515. //
  516. BOOL CMicroDriverAPI::IsValidRestriction(LONG **ppList, LONG *plNumItems, RANGEVALUEEX *pRangeValues)
  517. {
  518. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  519. WIALOG_NO_RESOURCE_ID,
  520. WIALOG_LEVEL1,
  521. "CMicroDriverAPI::IsValidRestriction");
  522. // set list pointer to null
  523. *ppList = NULL;
  524. LONG *pList = NULL;
  525. // set number of items to zero
  526. LONG lNumItems = 0;
  527. *plNumItems = 0;
  528. // set range stucture to zeros
  529. pRangeValues->lMax = 0;
  530. pRangeValues->lMin = 0;
  531. pRangeValues->lNom = 0;
  532. pRangeValues->lStep = 0;
  533. // string size check
  534. if(lstrlen(m_szResolutions) <= 0)
  535. return FALSE;
  536. // valid range or list check
  537. TCHAR *psz = NULL;
  538. CHAR szTemp[20];
  539. // valid range?
  540. INT iErrorCode = EOF;
  541. BOOL bValidRange = FALSE;
  542. psz = TSTRSTR(m_szResolutions,TEXT("MIN"));
  543. if (psz) {
  544. psz = TSTRSTR(psz,TEXT(" "));
  545. if (psz) {
  546. iErrorCode = TSSCANF(psz,TEXT("%d"),&pRangeValues->lMin);
  547. psz = NULL;
  548. psz = TSTRSTR(m_szResolutions,TEXT("MAX"));
  549. if ((psz)&&(iErrorCode != 0)&&(iErrorCode != EOF)) {
  550. psz = TSTRSTR(psz,TEXT(" "));
  551. if (psz) {
  552. iErrorCode = TSSCANF(psz,TEXT("%d"),&pRangeValues->lMax);
  553. psz = NULL;
  554. psz = TSTRSTR(m_szResolutions,TEXT("NOM"));
  555. if ((psz)&&(iErrorCode != 0)&&(iErrorCode != EOF)) {
  556. psz = TSTRSTR(psz,TEXT(" "));
  557. if (psz) {
  558. iErrorCode = TSSCANF(psz,TEXT("%d"),&pRangeValues->lNom);
  559. psz = NULL;
  560. psz = TSTRSTR(m_szResolutions,TEXT("INC"));
  561. if ((psz)&&(iErrorCode != 0)&&(iErrorCode != EOF)) {
  562. psz = TSTRSTR(psz,TEXT(" "));
  563. if (psz) {
  564. iErrorCode = TSSCANF(psz,TEXT("%d"),&pRangeValues->lStep);
  565. if ((iErrorCode != 0)&&(iErrorCode != EOF)) {
  566. bValidRange = TRUE;
  567. }
  568. }
  569. }
  570. }
  571. }
  572. }
  573. }
  574. }
  575. // check that range values are valid (to the definition of a RANGE)
  576. if (bValidRange) {
  577. if (pRangeValues->lMin > pRangeValues->lMax)
  578. return FALSE;
  579. if (pRangeValues->lNom > pRangeValues->lMax)
  580. return FALSE;
  581. if (pRangeValues->lStep > pRangeValues->lMax)
  582. return FALSE;
  583. if (pRangeValues->lNom < pRangeValues->lMin)
  584. return FALSE;
  585. }
  586. }
  587. if(!bValidRange){
  588. // set range stucture to zeros (invalid range settings)
  589. pRangeValues->lMax = 0;
  590. pRangeValues->lMin = 0;
  591. pRangeValues->lNom = 0;
  592. pRangeValues->lStep = 0;
  593. LONG lTempResArray[255];
  594. memset(lTempResArray,0,sizeof(lTempResArray));
  595. // not valid range?..what about a valid list?
  596. // valid list?
  597. psz = m_szResolutions;
  598. while(psz){
  599. // save value if one is found
  600. if(psz){
  601. iErrorCode = TSSCANF(psz,TEXT("%d"),&lTempResArray[lNumItems]);
  602. if((iErrorCode == EOF)||(iErrorCode == 0)) {
  603. // could not extract a value, assume invalid Resolution
  604. // was found.
  605. lNumItems = 0;
  606. break;
  607. }
  608. if(lTempResArray[lNumItems] <= 0){
  609. // quit list iteration.. an invalid Resolution was found
  610. lNumItems = 0;
  611. break;
  612. }
  613. lNumItems++;
  614. }
  615. // seek to next value
  616. psz = TSTRSTR(psz,TEXT(","));
  617. if(psz) {
  618. // move past ',' marker
  619. psz++;
  620. }
  621. }
  622. if (lNumItems > 0) {
  623. // create list, and send it back to caller
  624. pList = new LONG[lNumItems];
  625. if (!pList)
  626. return FALSE;
  627. for (LONG i = 0; i < lNumItems ; i++) {
  628. pList[i] = lTempResArray[i];
  629. }
  630. *plNumItems = lNumItems;
  631. *ppList = pList;
  632. } else {
  633. return FALSE;
  634. }
  635. }
  636. return TRUE;
  637. }
  638. //
  639. // button
  640. //
  641. HRESULT CMicroDriverAPI::QueryButtonPanel(PDEVICE_BUTTON_INFO pButtonInformation)
  642. {
  643. HRESULT hr = S_OK;
  644. return hr;
  645. }
  646. HRESULT CMicroDriverAPI::BuildCapabilities(PWIACAPABILITIES pCaps)
  647. {
  648. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  649. WIALOG_NO_RESOURCE_ID,
  650. WIALOG_LEVEL1,
  651. "CMicroDriverAPI::BuildCapabilities");
  652. //
  653. // validate incoming parameters, and return E_INVALIDARG as needed
  654. //
  655. if (!pCaps) {
  656. return E_INVALIDARG;
  657. }
  658. HRESULT hr = S_OK;
  659. VAL Val;
  660. memset(&Val,0,sizeof(Val));
  661. Val.pScanInfo = &m_ScanInfo;
  662. WCHAR **ppszButtonNames = NULL;
  663. hr = m_pMicroDriver->MicroEntry(CMD_GETCAPABILITIES,&Val);
  664. if (SUCCEEDED(hr)) {
  665. //
  666. // if this API is called with pCaps->pCapabilities == NULL, then return the
  667. // total number of additional events.
  668. //
  669. if (NULL == pCaps->pCapabilities) {
  670. if ((Val.lVal >= 0) && (Val.lVal < MAX_CAPABILITIES)) {
  671. *pCaps->pNumSupportedEvents = Val.lVal;
  672. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("BuildCapabilities, Additional Supported Events from MicroDriver = %d",Val.lVal));
  673. } else {
  674. hr = E_INVALIDARG;
  675. }
  676. } else {
  677. //
  678. // populate the capabilities array with names and descriptions
  679. //
  680. for (LONG index = 0; index < Val.lVal; index++) {
  681. ppszButtonNames = Val.ppButtonNames;
  682. //
  683. // allocate capability memory, for names, and descriptions
  684. //
  685. //
  686. // calculate size in BYTES for maximium string value
  687. // allowed by a capability
  688. //
  689. LONG lMaxCapabilityString = (MAX_PATH * sizeof(WCHAR));
  690. pCaps->pCapabilities[index].wszName = (LPOLESTR)CoTaskMemAlloc(lMaxCapabilityString);
  691. pCaps->pCapabilities[index].wszDescription = (LPOLESTR)CoTaskMemAlloc(lMaxCapabilityString);
  692. if ((pCaps->pCapabilities[index].wszDescription)&&
  693. (pCaps->pCapabilities[index].wszName)) {
  694. pCaps->pCapabilities[index].wszName[(lMaxCapabilityString/sizeof(WCHAR)) - 1] = L'\0';
  695. pCaps->pCapabilities[index].wszDescription[(lMaxCapabilityString/sizeof(WCHAR)) - 1] = L'\0';
  696. if (ppszButtonNames) {
  697. //
  698. // copy button name
  699. //
  700. if (lstrcpyn(pCaps->pCapabilities[index].wszName,ppszButtonNames[index],(lMaxCapabilityString/sizeof(WCHAR)) - 1)) {
  701. //
  702. // copy button name, into button description (they are the same for Micro drivers)
  703. //
  704. if (!lstrcpyn(pCaps->pCapabilities[index].wszDescription,pCaps->pCapabilities[index].wszName,(lMaxCapabilityString/sizeof(WCHAR)) - 1)) {
  705. //
  706. // continue, allowing the other events to be read
  707. //
  708. }
  709. }
  710. } else {
  711. //
  712. // do default WIA provided Names for buttons (1,2,3,4,5,...etc)
  713. //
  714. WCHAR wszEventName[MAX_PATH];
  715. memset(wszEventName,0,sizeof(wszEventName));
  716. //
  717. // load default button name from resource
  718. //
  719. if(LoadStringW(g_hInst,IDS_DEFAULT_EVENT_NAME,wszEventName,(sizeof(wszEventName)/sizeof(wszEventName[0])))) {
  720. _snwprintf(pCaps->pCapabilities[index].wszName,
  721. ((lMaxCapabilityString/sizeof(WCHAR)) - 1),
  722. L"%ws %d",
  723. wszEventName,
  724. (index + 1));
  725. if (!lstrcpyn(pCaps->pCapabilities[index].wszDescription,pCaps->pCapabilities[index].wszName,(lMaxCapabilityString/sizeof(WCHAR)) - 1)) {
  726. //
  727. // continue, allowing the other events to be read
  728. //
  729. }
  730. }
  731. }
  732. //
  733. // assign 'ACTION' to events
  734. //
  735. if(Val.pGuid) {
  736. pCaps->pCapabilities[index].guid = &Val.pGuid[index];
  737. }
  738. pCaps->pCapabilities[index].ulFlags = WIA_NOTIFICATION_EVENT|WIA_ACTION_EVENT;
  739. pCaps->pCapabilities[index].wszIcon = WIA_ICON_SCAN_BUTTON_PRESS;
  740. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("BuildCapabilities, Button Name = %ws",pCaps->pCapabilities[index].wszName));
  741. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("BuildCapabilities, Button Desc = %ws",pCaps->pCapabilities[index].wszDescription));
  742. } else {
  743. hr = E_OUTOFMEMORY;
  744. }// if ((pCaps->pCapabilities[index].wszDescription)&&(pCaps->pCapabilities[index].wszName))
  745. } // for (LONG index = 0; index < Val.lVal; index++)
  746. }
  747. }
  748. return hr;
  749. }
  750. HRESULT CMicroDriverAPI::GetBedWidthAndHeight(PLONG pWidth, PLONG pHeight)
  751. {
  752. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  753. WIALOG_NO_RESOURCE_ID,
  754. WIALOG_LEVEL1,
  755. "CMicroDriverAPI::GetBedWidthAndHeight");
  756. HRESULT hr = S_OK;
  757. *pWidth = m_ScanInfo.BedWidth;
  758. *pHeight = m_ScanInfo.BedHeight;
  759. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("CMicroDriverAPI::GetBedWidthAndHeight, Width = %d, Height = %d",m_ScanInfo.BedWidth,m_ScanInfo.BedHeight));
  760. return hr;
  761. }
  762. HRESULT CMicroDriverAPI::BuildRootItemProperties(PWIAPROPERTIES pProperties)
  763. {
  764. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  765. WIALOG_NO_RESOURCE_ID,
  766. WIALOG_LEVEL1,
  767. "CMicroDriverAPI::BuildRootItemProperties");
  768. HRESULT hr = S_OK;
  769. LONG PropIndex = 0;
  770. //
  771. // set the number of properties
  772. //
  773. hr = ADFAttached();
  774. if(hr == S_OK){
  775. pProperties->NumItemProperties = 19; // standard properties + ADF specific
  776. } else {
  777. pProperties->NumItemProperties = 10; // standard properties only
  778. }
  779. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("CMicroDriverAPI::BuildRootItemProperties, Number of Properties = %d",pProperties->NumItemProperties));
  780. hr = AllocateAllProperties(pProperties);
  781. if(FAILED(hr)){
  782. WIAS_LERROR(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,("CMicroDriverAPI::BuildRootItemProperties, AllocateAllProperties failed"));
  783. WIAS_LHRESULT(m_pIWiaLog, hr);
  784. DeleteAllProperties(pProperties);
  785. return hr;
  786. }
  787. // Intialize WIA_DPS_HORIZONTAL_BED_SIZE
  788. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_HORIZONTAL_BED_SIZE_STR;
  789. pProperties->piItemDefaults [PropIndex] = WIA_DPS_HORIZONTAL_BED_SIZE;
  790. pProperties->pvItemDefaults [PropIndex].lVal = m_ScanInfo.BedWidth;
  791. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  792. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  793. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  794. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  795. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  796. PropIndex++;
  797. // Intialize WIA_DPS_VERTICAL_BED_SIZE
  798. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_VERTICAL_BED_SIZE_STR;
  799. pProperties->piItemDefaults [PropIndex] = WIA_DPS_VERTICAL_BED_SIZE;
  800. pProperties->pvItemDefaults [PropIndex].lVal = m_ScanInfo.BedHeight;
  801. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  802. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  803. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  804. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  805. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  806. PropIndex++;
  807. // Intialize WIA_IPA_ACCESS_RIGHTS
  808. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_ACCESS_RIGHTS_STR;
  809. pProperties->piItemDefaults [PropIndex] = WIA_IPA_ACCESS_RIGHTS;
  810. pProperties->pvItemDefaults [PropIndex].lVal = WIA_ITEM_READ|WIA_ITEM_WRITE;
  811. pProperties->pvItemDefaults [PropIndex].vt = VT_UI4;
  812. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  813. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  814. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  815. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  816. PropIndex++;
  817. // Intialize WIA_DPS_OPTICAL_XRES
  818. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_OPTICAL_XRES_STR;
  819. pProperties->piItemDefaults [PropIndex] = WIA_DPS_OPTICAL_XRES;
  820. pProperties->pvItemDefaults [PropIndex].lVal = m_ScanInfo.OpticalXResolution;
  821. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  822. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  823. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  824. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  825. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  826. PropIndex++;
  827. // Intialize WIA_DPS_OPTICAL_YRES
  828. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_OPTICAL_YRES_STR;
  829. pProperties->piItemDefaults [PropIndex] = WIA_DPS_OPTICAL_YRES;
  830. pProperties->pvItemDefaults [PropIndex].lVal = m_ScanInfo.OpticalYResolution;
  831. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  832. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  833. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  834. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  835. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  836. PropIndex++;
  837. // Initialize WIA_DPA_FIRMWARE_VERSION
  838. pProperties->pszItemDefaults[PropIndex] = WIA_DPA_FIRMWARE_VERSION_STR;
  839. pProperties->piItemDefaults [PropIndex] = WIA_DPA_FIRMWARE_VERSION;
  840. pProperties->pvItemDefaults [PropIndex].bstrVal = SysAllocString(SCANNER_FIRMWARE_VERSION);
  841. pProperties->pvItemDefaults [PropIndex].vt = VT_BSTR;
  842. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  843. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  844. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  845. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  846. PropIndex++;
  847. // Initialize WIA_IPA_ITEM_FLAGS
  848. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_ITEM_FLAGS_STR;
  849. pProperties->piItemDefaults [PropIndex] = WIA_IPA_ITEM_FLAGS;
  850. pProperties->pvItemDefaults [PropIndex].lVal = WiaItemTypeRoot|WiaItemTypeFolder|WiaItemTypeDevice;
  851. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  852. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  853. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  854. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_FLAG;
  855. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  856. pProperties->wpiItemDefaults[PropIndex].ValidVal.Flag.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  857. pProperties->wpiItemDefaults[PropIndex].ValidVal.Flag.ValidBits = WiaItemTypeRoot|WiaItemTypeFolder|WiaItemTypeDevice;
  858. PropIndex++;
  859. // Intialize WIA_DPS_MAX_SCAN_TIME (NONE)
  860. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_MAX_SCAN_TIME_STR;
  861. pProperties->piItemDefaults [PropIndex] = WIA_DPS_MAX_SCAN_TIME;
  862. pProperties->pvItemDefaults [PropIndex].lVal = 10000;
  863. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  864. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  865. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  866. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  867. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  868. PropIndex++;
  869. // Intialize WIA_DPS_PREVIEW (LIST)
  870. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_PREVIEW_STR;
  871. pProperties->piItemDefaults [PropIndex] = WIA_DPS_PREVIEW;
  872. pProperties->pvItemDefaults [PropIndex].lVal = WIA_FINAL_SCAN;
  873. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  874. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  875. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  876. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_LIST;
  877. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  878. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.pList= (BYTE*)pProperties->pSupportedPreviewModes;
  879. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  880. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.cNumList = pProperties->NumSupportedPreviewModes;
  881. PropIndex++;
  882. // Initialize WIA_DPS_SHOW_PREVIEW_CONTROL (NONE)
  883. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_SHOW_PREVIEW_CONTROL_STR;
  884. pProperties->piItemDefaults [PropIndex] = WIA_DPS_SHOW_PREVIEW_CONTROL;
  885. pProperties->pvItemDefaults [PropIndex].lVal = WIA_SHOW_PREVIEW_CONTROL;
  886. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  887. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  888. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  889. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  890. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  891. PropIndex++;
  892. if(m_ScanInfo.ADF == 1) {
  893. // Initialize WIA_DPS_HORIZONTAL_SHEET_FEED_SIZE
  894. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_HORIZONTAL_SHEET_FEED_SIZE_STR;
  895. pProperties->piItemDefaults [PropIndex] = WIA_DPS_HORIZONTAL_SHEET_FEED_SIZE;
  896. pProperties->pvItemDefaults [PropIndex].lVal = m_ScanInfo.BedWidth;
  897. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  898. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  899. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  900. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  901. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  902. PropIndex++;
  903. // Initialize WIA_DPS_VERTICAL_SHEET_FEED_SIZE
  904. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_VERTICAL_SHEET_FEED_SIZE_STR;
  905. pProperties->piItemDefaults [PropIndex] = WIA_DPS_VERTICAL_SHEET_FEED_SIZE;
  906. pProperties->pvItemDefaults [PropIndex].lVal = m_ScanInfo.BedHeight;
  907. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  908. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  909. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  910. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  911. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  912. PropIndex++;
  913. // Initialize WIA_DPS_DOCUMENT_HANDLING_CAPABILITIES
  914. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_DOCUMENT_HANDLING_CAPABILITIES_STR;
  915. pProperties->piItemDefaults [PropIndex] = WIA_DPS_DOCUMENT_HANDLING_CAPABILITIES;
  916. pProperties->pvItemDefaults [PropIndex].lVal = FLAT | FEED;
  917. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  918. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  919. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  920. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_FLAG;
  921. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  922. PropIndex++;
  923. // Initialize WIA_DPS_DOCUMENT_HANDLING_STATUS
  924. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_DOCUMENT_HANDLING_STATUS_STR;
  925. pProperties->piItemDefaults [PropIndex] = WIA_DPS_DOCUMENT_HANDLING_STATUS;
  926. pProperties->pvItemDefaults [PropIndex].lVal = FLAT_READY;
  927. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  928. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  929. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  930. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  931. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  932. PropIndex++;
  933. // Initialize WIA_DPS_DOCUMENT_HANDLING_SELECT
  934. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_DOCUMENT_HANDLING_SELECT_STR;
  935. pProperties->piItemDefaults [PropIndex] = WIA_DPS_DOCUMENT_HANDLING_SELECT;
  936. pProperties->pvItemDefaults [PropIndex].lVal = FLATBED;
  937. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  938. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  939. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  940. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_FLAG;
  941. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  942. pProperties->wpiItemDefaults[PropIndex].ValidVal.Flag.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  943. pProperties->wpiItemDefaults[PropIndex].ValidVal.Flag.ValidBits = FEEDER | FLATBED;
  944. PropIndex++;
  945. // Initialize WIA_DPS_PAGES
  946. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_PAGES_STR;
  947. pProperties->piItemDefaults [PropIndex] = WIA_DPS_PAGES;
  948. pProperties->pvItemDefaults [PropIndex].lVal = 1;
  949. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  950. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  951. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  952. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_RANGE;
  953. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  954. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Inc = 1;
  955. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Min = 0;
  956. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Max = 25;
  957. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Nom = 1;
  958. PropIndex++;
  959. // Initialize WIA_DPS_SHEET_FEEDER_REGISTRATION
  960. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_SHEET_FEEDER_REGISTRATION_STR;
  961. pProperties->piItemDefaults [PropIndex] = WIA_DPS_SHEET_FEEDER_REGISTRATION;
  962. pProperties->pvItemDefaults [PropIndex].lVal = LEFT_JUSTIFIED;
  963. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  964. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  965. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  966. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  967. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  968. PropIndex++;
  969. // Initialize WIA_DPS_HORIZONTAL_BED_REGISTRATION
  970. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_HORIZONTAL_BED_REGISTRATION_STR;
  971. pProperties->piItemDefaults [PropIndex] = WIA_DPS_HORIZONTAL_BED_REGISTRATION;
  972. pProperties->pvItemDefaults [PropIndex].lVal = LEFT_JUSTIFIED;
  973. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  974. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  975. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  976. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  977. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  978. PropIndex++;
  979. // Initialize WIA_DPS_VERTICAL_BED_REGISTRATION
  980. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_VERTICAL_BED_REGISTRATION_STR;
  981. pProperties->piItemDefaults [PropIndex] = WIA_DPS_VERTICAL_BED_REGISTRATION;
  982. pProperties->pvItemDefaults [PropIndex].lVal = TOP_JUSTIFIED;
  983. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  984. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  985. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  986. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  987. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  988. PropIndex++;
  989. }
  990. return hr;
  991. }
  992. HRESULT CMicroDriverAPI::DeleteAllProperties(PWIAPROPERTIES pProperties)
  993. {
  994. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  995. WIALOG_NO_RESOURCE_ID,
  996. WIALOG_LEVEL1,
  997. "CMicroDriverAPI::DeleteAllProperties");
  998. if(pProperties->pszItemDefaults){
  999. delete [] pProperties->pszItemDefaults;
  1000. pProperties->pszItemDefaults = NULL;
  1001. }
  1002. if(pProperties->piItemDefaults){
  1003. delete [] pProperties->piItemDefaults;
  1004. pProperties->piItemDefaults = NULL;
  1005. }
  1006. if(pProperties->pvItemDefaults){
  1007. delete [] pProperties->pvItemDefaults;
  1008. pProperties->pvItemDefaults = NULL;
  1009. }
  1010. if(pProperties->psItemDefaults){
  1011. delete [] pProperties->psItemDefaults;
  1012. pProperties->psItemDefaults = NULL;
  1013. }
  1014. if(pProperties->wpiItemDefaults){
  1015. delete [] pProperties->wpiItemDefaults;
  1016. pProperties->wpiItemDefaults = NULL;
  1017. }
  1018. return S_OK;
  1019. }
  1020. HRESULT CMicroDriverAPI::AllocateAllProperties(PWIAPROPERTIES pProperties)
  1021. {
  1022. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  1023. WIALOG_NO_RESOURCE_ID,
  1024. WIALOG_LEVEL1,
  1025. "CMicroDriverAPI::AllocateAllProperties");
  1026. HRESULT hr = S_OK;
  1027. pProperties->pszItemDefaults = new LPOLESTR[pProperties->NumItemProperties];
  1028. if(NULL != pProperties->pszItemDefaults){
  1029. pProperties->piItemDefaults = new PROPID[pProperties->NumItemProperties];
  1030. if (NULL != pProperties->piItemDefaults) {
  1031. pProperties->pvItemDefaults = new PROPVARIANT[pProperties->NumItemProperties];
  1032. if(NULL != pProperties->pvItemDefaults){
  1033. pProperties->psItemDefaults = new PROPSPEC[pProperties->NumItemProperties];
  1034. if(NULL != pProperties->psItemDefaults){
  1035. pProperties->wpiItemDefaults = new WIA_PROPERTY_INFO[pProperties->NumItemProperties];
  1036. if(NULL == pProperties->wpiItemDefaults)
  1037. hr = E_OUTOFMEMORY;
  1038. } else
  1039. hr = E_OUTOFMEMORY;
  1040. } else
  1041. hr = E_OUTOFMEMORY;
  1042. } else
  1043. hr = E_OUTOFMEMORY;
  1044. } else
  1045. hr = E_OUTOFMEMORY;
  1046. return hr;
  1047. }
  1048. HRESULT CMicroDriverAPI::BuildTopItemProperties(PWIAPROPERTIES pProperties)
  1049. {
  1050. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  1051. WIALOG_NO_RESOURCE_ID,
  1052. WIALOG_LEVEL1,
  1053. "CMicroDriverAPI::BuildTopItemProperties");
  1054. HRESULT hr = S_OK;
  1055. VAL Value;
  1056. memset(&Value,0,sizeof(Value));
  1057. Value.pScanInfo = &m_ScanInfo;
  1058. hr = m_pMicroDriver->MicroEntry(CMD_RESETSCANNER,&Value);
  1059. if(FAILED(hr)){
  1060. return hr;
  1061. }
  1062. //
  1063. // set the number of properties
  1064. //
  1065. pProperties->NumItemProperties = 29;
  1066. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("CMicroDriverAPI::BuildTopItemProperties, Number of Properties = %d",pProperties->NumItemProperties));
  1067. hr = AllocateAllProperties(pProperties);
  1068. if(FAILED(hr)){
  1069. WIAS_LERROR(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,("CMicroDriverAPI::BuildTopItemProperties, AllocateAllProperties failed"));
  1070. WIAS_LHRESULT(m_pIWiaLog, hr);
  1071. DeleteAllProperties(pProperties);
  1072. return hr;
  1073. }
  1074. //
  1075. // Get Data type restrictions (backup original data types)
  1076. // Memory used for the original set will be reused to write back
  1077. // the new valid values.
  1078. //
  1079. if(pProperties->bLegacyBWRestrictions){
  1080. //
  1081. // The NoColor=1 registry key was set to restrict this driver from supporting
  1082. // color... remove the valid bits, just incase the bits were set..
  1083. // This will automatically restrict our Data type array to report
  1084. // the correct valid values.
  1085. m_ScanInfo.SupportedDataTypes &= ~SUPPORT_COLOR;
  1086. }
  1087. LONG lSupportedDataTypesArray[3]; // 3 is the maximum data type set allowed
  1088. LONG lNumSupportedDataTypes = 0;
  1089. memcpy(lSupportedDataTypesArray,pProperties->pSupportedDataTypes,(sizeof(lSupportedDataTypesArray)));
  1090. //
  1091. // Set New Data type restrictions
  1092. //
  1093. if (m_ScanInfo.SupportedDataTypes != 0) {
  1094. // check for 24-bit color support
  1095. if (m_ScanInfo.SupportedDataTypes & SUPPORT_COLOR) {
  1096. pProperties->pSupportedDataTypes[lNumSupportedDataTypes] = WIA_DATA_COLOR;
  1097. lNumSupportedDataTypes++;
  1098. }
  1099. // check for 1-bit BW support
  1100. if (m_ScanInfo.SupportedDataTypes & SUPPORT_BW) {
  1101. pProperties->pSupportedDataTypes[lNumSupportedDataTypes] = WIA_DATA_THRESHOLD;
  1102. lNumSupportedDataTypes++;
  1103. }
  1104. // check for 8-bit grayscale support
  1105. if (m_ScanInfo.SupportedDataTypes & SUPPORT_GRAYSCALE) {
  1106. pProperties->pSupportedDataTypes[lNumSupportedDataTypes] = WIA_DATA_GRAYSCALE;
  1107. lNumSupportedDataTypes++;
  1108. }
  1109. // set new supported data type count
  1110. pProperties->NumSupportedDataTypes = lNumSupportedDataTypes;
  1111. }
  1112. LONG PropIndex = 0;
  1113. PLONG pResolutions = NULL;
  1114. LONG lNumItems = 0;
  1115. RANGEVALUEEX RangeValues;
  1116. if(IsValidRestriction(&pResolutions, &lNumItems, &RangeValues)) {
  1117. if(lNumItems > 0){
  1118. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("BuildTopItemProperties, Using .INF provided Resolutions (LIST)"));
  1119. // we have a list
  1120. if(pProperties->pSupportedResolutions){
  1121. //delete [] pProperties->pSupportedResolutions;
  1122. pProperties->pSupportedResolutions = NULL;
  1123. pProperties->pSupportedResolutions = pResolutions;
  1124. pProperties->NumSupportedResolutions = lNumItems;
  1125. }
  1126. // Intialize WIA_IPS_XRES (LIST)
  1127. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_XRES_STR;
  1128. pProperties->piItemDefaults [PropIndex] = WIA_IPS_XRES;
  1129. pProperties->pvItemDefaults [PropIndex].lVal = pProperties->pSupportedResolutions[PropIndex];
  1130. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1131. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1132. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1133. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_LIST;
  1134. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1135. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.pList= (BYTE*)pProperties->pSupportedResolutions;
  1136. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1137. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.cNumList = pProperties->NumSupportedResolutions;
  1138. PropIndex++;
  1139. // Intialize WIA_IPS_YRES (LIST)
  1140. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_YRES_STR;
  1141. pProperties->piItemDefaults [PropIndex] = WIA_IPS_YRES;
  1142. pProperties->pvItemDefaults [PropIndex].lVal = pProperties->pSupportedResolutions[PropIndex-1];
  1143. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1144. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1145. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1146. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_LIST;
  1147. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1148. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.pList= (BYTE*)pProperties->pSupportedResolutions;
  1149. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1150. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.cNumList = pProperties->NumSupportedResolutions;
  1151. PropIndex++;
  1152. } else {
  1153. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("BuildTopItemProperties, Using .INF provided Resolutions (RANGE)"));
  1154. // we have a range
  1155. // Intialize WIA_IPS_XRES (RANGE)
  1156. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_XRES_STR;
  1157. pProperties->piItemDefaults [PropIndex] = WIA_IPS_XRES;
  1158. pProperties->pvItemDefaults [PropIndex].lVal = RangeValues.lNom;
  1159. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1160. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1161. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1162. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_RANGE;
  1163. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1164. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Inc = RangeValues.lStep;
  1165. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Min = RangeValues.lMin;
  1166. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Max = RangeValues.lMax;
  1167. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Nom = RangeValues.lNom;
  1168. PropIndex++;
  1169. // Intialize WIA_IPS_YRES (RANGE)
  1170. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_YRES_STR;
  1171. pProperties->piItemDefaults [PropIndex] = WIA_IPS_YRES;
  1172. pProperties->pvItemDefaults [PropIndex].lVal = RangeValues.lNom;
  1173. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1174. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1175. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1176. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_RANGE;
  1177. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1178. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Inc = RangeValues.lStep;
  1179. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Min = RangeValues.lMin;
  1180. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Max = RangeValues.lMax;
  1181. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Nom = RangeValues.lNom;
  1182. PropIndex++;
  1183. }
  1184. } else {
  1185. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("BuildTopItemProperties, Using HOST Provided Resolution Restrictions"));
  1186. #ifdef USE_RANGE_VALUES
  1187. // Intialize WIA_IPS_XRES (RANGE)
  1188. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_XRES_STR;
  1189. pProperties->piItemDefaults [PropIndex] = WIA_IPS_XRES;
  1190. pProperties->pvItemDefaults [PropIndex].lVal = INITIAL_XRESOLUTION;
  1191. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1192. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1193. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1194. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_RANGE;
  1195. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1196. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Inc = 1;
  1197. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Min = 12;
  1198. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Max = 1200;
  1199. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1200. PropIndex++;
  1201. // Intialize WIA_IPS_YRES (RANGE)
  1202. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_YRES_STR;
  1203. pProperties->piItemDefaults [PropIndex] = WIA_IPS_YRES;
  1204. pProperties->pvItemDefaults [PropIndex].lVal = INITIAL_YRESOLUTION;
  1205. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1206. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1207. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1208. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_RANGE;
  1209. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1210. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Inc = 1;
  1211. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Min = 12;
  1212. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Max = 1200;
  1213. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1214. PropIndex++;
  1215. #else // USE_RANGE_VALUES (different property sets for different drivers)
  1216. // Intialize WIA_IPS_XRES (LIST)
  1217. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_XRES_STR;
  1218. pProperties->piItemDefaults [PropIndex] = WIA_IPS_XRES;
  1219. pProperties->pvItemDefaults [PropIndex].lVal = INITIAL_XRESOLUTION;
  1220. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1221. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1222. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1223. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_LIST;
  1224. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1225. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.pList= (BYTE*)pProperties->pSupportedResolutions;
  1226. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1227. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.cNumList = pProperties->NumSupportedResolutions;
  1228. PropIndex++;
  1229. // Intialize WIA_IPS_YRES (LIST)
  1230. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_YRES_STR;
  1231. pProperties->piItemDefaults [PropIndex] = WIA_IPS_YRES;
  1232. pProperties->pvItemDefaults [PropIndex].lVal = INITIAL_YRESOLUTION;
  1233. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1234. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1235. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1236. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_LIST;
  1237. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1238. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.pList= (BYTE*)pProperties->pSupportedResolutions;
  1239. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1240. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.cNumList = pProperties->NumSupportedResolutions;
  1241. PropIndex++;
  1242. #endif
  1243. }
  1244. // Intialize WIA_IPS_XEXTENT (RANGE)
  1245. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_XEXTENT_STR;
  1246. pProperties->piItemDefaults [PropIndex] = WIA_IPS_XEXTENT;
  1247. pProperties->pvItemDefaults [PropIndex].lVal = (pProperties->pvItemDefaults [PropIndex-2].lVal * m_ScanInfo.BedWidth)/1000;
  1248. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1249. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1250. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1251. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_RANGE;
  1252. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1253. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Inc = 1;
  1254. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Min = 1;
  1255. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Max = pProperties->pvItemDefaults [PropIndex].lVal;
  1256. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1257. PropIndex++;
  1258. // Intialize WIA_IPS_YEXTENT (RANGE)
  1259. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_YEXTENT_STR;
  1260. pProperties->piItemDefaults [PropIndex] = WIA_IPS_YEXTENT;
  1261. pProperties->pvItemDefaults [PropIndex].lVal = (pProperties->pvItemDefaults [PropIndex-2].lVal * m_ScanInfo.BedHeight)/1000;;
  1262. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1263. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1264. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1265. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_RANGE;
  1266. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1267. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Inc = 1;
  1268. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Min = 1;
  1269. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Max = pProperties->pvItemDefaults [PropIndex].lVal;
  1270. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1271. PropIndex++;
  1272. // Intialize WIA_IPS_XPOS (RANGE)
  1273. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_XPOS_STR;
  1274. pProperties->piItemDefaults [PropIndex] = WIA_IPS_XPOS;
  1275. pProperties->pvItemDefaults [PropIndex].lVal = 0;
  1276. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1277. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1278. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1279. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_RANGE;
  1280. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1281. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Inc = 1;
  1282. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Min = 0;
  1283. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Max = (pProperties->wpiItemDefaults[PropIndex-2].ValidVal.Range.Max - 1);
  1284. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1285. PropIndex++;
  1286. // Intialize WIA_IPS_YPOS (RANGE)
  1287. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_YPOS_STR;
  1288. pProperties->piItemDefaults [PropIndex] = WIA_IPS_YPOS;
  1289. pProperties->pvItemDefaults [PropIndex].lVal = 0;
  1290. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1291. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1292. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1293. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_RANGE;
  1294. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1295. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Inc = 1;
  1296. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Min = 0;
  1297. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Max = (pProperties->wpiItemDefaults[PropIndex-2].ValidVal.Range.Max - 1);
  1298. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1299. PropIndex++;
  1300. // Intialize WIA_IPA_DATATYPE (LIST)
  1301. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_DATATYPE_STR;
  1302. pProperties->piItemDefaults [PropIndex] = WIA_IPA_DATATYPE;
  1303. pProperties->pvItemDefaults [PropIndex].lVal = m_ScanInfo.DataType;
  1304. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1305. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1306. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1307. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_LIST;
  1308. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1309. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.pList = (BYTE*)pProperties->pSupportedDataTypes;
  1310. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1311. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.cNumList = pProperties->NumSupportedDataTypes;
  1312. PropIndex++;
  1313. // Intialize WIA_IPA_DEPTH (NONE)
  1314. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_DEPTH_STR;
  1315. pProperties->piItemDefaults [PropIndex] = WIA_IPA_DEPTH;
  1316. pProperties->pvItemDefaults [PropIndex].lVal = m_ScanInfo.PixelBits;
  1317. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1318. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1319. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1320. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  1321. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1322. PropIndex++;
  1323. // Intialize WIA_IPS_BRIGHTNESS (RANGE)
  1324. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_BRIGHTNESS_STR;
  1325. pProperties->piItemDefaults [PropIndex] = WIA_IPS_BRIGHTNESS;
  1326. pProperties->pvItemDefaults [PropIndex].lVal = m_ScanInfo.Intensity;//INITIAL_BRIGHTNESS;
  1327. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1328. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1329. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1330. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_RANGE;
  1331. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1332. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Inc = m_ScanInfo.IntensityRange.lStep; // 1
  1333. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Min = m_ScanInfo.IntensityRange.lMin; //-127;
  1334. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Max = m_ScanInfo.IntensityRange.lMax; // 128;
  1335. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1336. PropIndex++;
  1337. // Intialize WIA_IPS_CONTRAST (RANGE)
  1338. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_CONTRAST_STR;
  1339. pProperties->piItemDefaults [PropIndex] = WIA_IPS_CONTRAST;
  1340. pProperties->pvItemDefaults [PropIndex].lVal = m_ScanInfo.Contrast;//INITIAL_CONTRAST;
  1341. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1342. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1343. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1344. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_RANGE;
  1345. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1346. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Inc = m_ScanInfo.ContrastRange.lStep; // 1
  1347. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Min = m_ScanInfo.ContrastRange.lMin; //-127;
  1348. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Max = m_ScanInfo.ContrastRange.lMax; // 128;
  1349. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1350. PropIndex++;
  1351. // Intialize WIA_IPS_CUR_INTENT (FLAG)
  1352. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_CUR_INTENT_STR;
  1353. pProperties->piItemDefaults [PropIndex] = WIA_IPS_CUR_INTENT;
  1354. pProperties->pvItemDefaults [PropIndex].lVal = WIA_INTENT_NONE;
  1355. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1356. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1357. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1358. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_FLAG;
  1359. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1360. pProperties->wpiItemDefaults[PropIndex].ValidVal.Flag.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1361. pProperties->wpiItemDefaults[PropIndex].ValidVal.Flag.ValidBits = WIA_INTENT_MINIMIZE_SIZE | WIA_INTENT_MAXIMIZE_QUALITY;
  1362. // check for 24-bit color support
  1363. if (m_ScanInfo.SupportedDataTypes & SUPPORT_COLOR) {
  1364. pProperties->wpiItemDefaults[PropIndex].ValidVal.Flag.ValidBits |= WIA_INTENT_IMAGE_TYPE_COLOR;
  1365. }
  1366. // check for 1-bit BW support
  1367. if (m_ScanInfo.SupportedDataTypes & SUPPORT_BW) {
  1368. pProperties->wpiItemDefaults[PropIndex].ValidVal.Flag.ValidBits |= WIA_INTENT_IMAGE_TYPE_TEXT;
  1369. }
  1370. // check for 8-bit grayscale support
  1371. if (m_ScanInfo.SupportedDataTypes & SUPPORT_GRAYSCALE) {
  1372. pProperties->wpiItemDefaults[PropIndex].ValidVal.Flag.ValidBits |= WIA_INTENT_IMAGE_TYPE_GRAYSCALE;
  1373. }
  1374. if(pProperties->bLegacyBWRestrictions){
  1375. //
  1376. // The NoColor=1 registry key was set to restrict this driver from supporting
  1377. // color... remove the valid bits, just incase the bits were set..
  1378. // note: NoColor overrides all driver settings
  1379. //
  1380. pProperties->wpiItemDefaults[PropIndex].ValidVal.Flag.ValidBits &= ~ WIA_INTENT_IMAGE_TYPE_COLOR;
  1381. }
  1382. //////////////////////////////////////////////////////////////////////////////////////////////////
  1383. // The full valid bits for intent for information only //
  1384. //////////////////////////////////////////////////////////////////////////////////////////////////
  1385. //
  1386. // pProperties->wpiItemDefaults[PropIndex].ValidVal.Flag.ValidBits = WIA_INTENT_IMAGE_TYPE_COLOR |
  1387. // WIA_INTENT_IMAGE_TYPE_GRAYSCALE |
  1388. // WIA_INTENT_IMAGE_TYPE_TEXT |
  1389. // WIA_INTENT_MINIMIZE_SIZE |
  1390. // WIA_INTENT_MAXIMIZE_QUALITY;
  1391. //////////////////////////////////////////////////////////////////////////////////////////////////
  1392. PropIndex++;
  1393. // Intialize WIA_IPA_PIXELS_PER_LINE (NONE)
  1394. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_PIXELS_PER_LINE_STR;
  1395. pProperties->piItemDefaults [PropIndex] = WIA_IPA_PIXELS_PER_LINE;
  1396. pProperties->pvItemDefaults [PropIndex].lVal = pProperties->pvItemDefaults [PropIndex-9].lVal;
  1397. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1398. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1399. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1400. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  1401. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1402. PropIndex++;
  1403. // Intialize WIA_IPA_NUMER_OF_LINES (NONE)
  1404. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_NUMBER_OF_LINES_STR;
  1405. pProperties->piItemDefaults [PropIndex] = WIA_IPA_NUMBER_OF_LINES;
  1406. pProperties->pvItemDefaults [PropIndex].lVal = pProperties->pvItemDefaults [PropIndex-9].lVal;
  1407. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1408. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1409. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1410. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  1411. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1412. PropIndex++;
  1413. // Intialize WIA_DPS_MAX_SCAN_TIME (NONE)
  1414. pProperties->pszItemDefaults[PropIndex] = WIA_DPS_MAX_SCAN_TIME_STR;
  1415. pProperties->piItemDefaults [PropIndex] = WIA_DPS_MAX_SCAN_TIME;
  1416. pProperties->pvItemDefaults [PropIndex].lVal = 10000;
  1417. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1418. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1419. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1420. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  1421. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1422. PropIndex++;
  1423. // Intialize WIA_IPA_PREFERRED_FORMAT (NONE)
  1424. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_PREFERRED_FORMAT_STR;
  1425. pProperties->piItemDefaults [PropIndex] = WIA_IPA_PREFERRED_FORMAT;
  1426. pProperties->pvItemDefaults [PropIndex].puuid = &pProperties->pInitialFormats[0];;
  1427. pProperties->pvItemDefaults [PropIndex].vt = VT_CLSID;
  1428. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1429. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1430. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  1431. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1432. PropIndex++;
  1433. // Intialize WIA_IPA_ITEM_SIZE (NONE)
  1434. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_ITEM_SIZE_STR;
  1435. pProperties->piItemDefaults [PropIndex] = WIA_IPA_ITEM_SIZE;
  1436. pProperties->pvItemDefaults [PropIndex].lVal = 0;
  1437. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1438. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1439. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1440. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  1441. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1442. PropIndex++;
  1443. // Intialize WIA_IPS_THRESHOLD (RANGE)
  1444. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_THRESHOLD_STR;
  1445. pProperties->piItemDefaults [PropIndex] = WIA_IPS_THRESHOLD;
  1446. pProperties->pvItemDefaults [PropIndex].lVal = 0;
  1447. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1448. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1449. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1450. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_RANGE;
  1451. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1452. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Inc = 1;
  1453. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Min = -127;
  1454. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Max = 128;
  1455. pProperties->wpiItemDefaults[PropIndex].ValidVal.Range.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1456. PropIndex++;
  1457. // Intialize WIA_IPA_FORMAT (LIST)
  1458. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_FORMAT_STR;
  1459. pProperties->piItemDefaults [PropIndex] = WIA_IPA_FORMAT;
  1460. pProperties->pvItemDefaults [PropIndex].puuid = &pProperties->pInitialFormats[0];
  1461. pProperties->pvItemDefaults [PropIndex].vt = VT_CLSID;
  1462. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1463. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1464. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_LIST;
  1465. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1466. pProperties->wpiItemDefaults[PropIndex].ValidVal.ListGuid.pList = pProperties->pInitialFormats;
  1467. pProperties->wpiItemDefaults[PropIndex].ValidVal.ListGuid.Nom = *pProperties->pvItemDefaults [PropIndex].puuid;
  1468. pProperties->wpiItemDefaults[PropIndex].ValidVal.ListGuid.cNumList = pProperties->NumInitialFormats;
  1469. PropIndex++;
  1470. // Intialize WIA_IPA_TYMED (LIST)
  1471. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_TYMED_STR;
  1472. pProperties->piItemDefaults [PropIndex] = WIA_IPA_TYMED;
  1473. pProperties->pvItemDefaults [PropIndex].lVal = INITIAL_TYMED;
  1474. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1475. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1476. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1477. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_LIST;
  1478. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1479. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.pList = (BYTE*)pProperties->pSupportedTYMED;
  1480. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1481. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.cNumList = pProperties->NumSupportedTYMED;
  1482. PropIndex++;
  1483. // Intialize WIA_IPA_CHANNELS_PER_PIXEL (NONE)
  1484. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_CHANNELS_PER_PIXEL_STR;
  1485. pProperties->piItemDefaults [PropIndex] = WIA_IPA_CHANNELS_PER_PIXEL;
  1486. pProperties->pvItemDefaults [PropIndex].lVal = INITIAL_CHANNELS_PER_PIXEL;
  1487. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1488. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1489. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1490. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  1491. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1492. PropIndex++;
  1493. // Intialize WIA_IPA_BITS_PER_CHANNEL (NONE)
  1494. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_BITS_PER_CHANNEL_STR;
  1495. pProperties->piItemDefaults [PropIndex] = WIA_IPA_BITS_PER_CHANNEL;
  1496. pProperties->pvItemDefaults [PropIndex].lVal = INITIAL_BITS_PER_CHANNEL;
  1497. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1498. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1499. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1500. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  1501. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1502. PropIndex++;
  1503. // Intialize WIA_IPA_PLANAR (NONE)
  1504. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_PLANAR_STR;
  1505. pProperties->piItemDefaults [PropIndex] = WIA_IPA_PLANAR;
  1506. pProperties->pvItemDefaults [PropIndex].lVal = INITIAL_PLANAR;
  1507. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1508. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1509. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1510. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  1511. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1512. PropIndex++;
  1513. // Intialize WIA_IPA_BYTES_PER_LINE (NONE)
  1514. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_BYTES_PER_LINE_STR;
  1515. pProperties->piItemDefaults [PropIndex] = WIA_IPA_BYTES_PER_LINE;
  1516. pProperties->pvItemDefaults [PropIndex].lVal = 0;
  1517. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1518. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1519. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1520. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  1521. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1522. PropIndex++;
  1523. // Intialize WIA_IPA_MIN_BUFFER_SIZE (NONE)
  1524. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_MIN_BUFFER_SIZE_STR;
  1525. pProperties->piItemDefaults [PropIndex] = WIA_IPA_MIN_BUFFER_SIZE;
  1526. pProperties->pvItemDefaults [PropIndex].lVal = MIN_BUFFER_SIZE;
  1527. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1528. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1529. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1530. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  1531. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1532. PropIndex++;
  1533. // Intialize WIA_IPA_ACCESS_RIGHTS (NONE)
  1534. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_ACCESS_RIGHTS_STR;
  1535. pProperties->piItemDefaults [PropIndex] = WIA_IPA_ACCESS_RIGHTS;
  1536. pProperties->pvItemDefaults [PropIndex].lVal = WIA_ITEM_READ|WIA_ITEM_WRITE;
  1537. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1538. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1539. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1540. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  1541. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1542. PropIndex++;
  1543. // Intialize WIA_IPA_COMPRESSION (LIST)
  1544. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_COMPRESSION_STR;
  1545. pProperties->piItemDefaults [PropIndex] = WIA_IPA_COMPRESSION;
  1546. pProperties->pvItemDefaults [PropIndex].lVal = INITIAL_COMPRESSION;
  1547. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1548. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1549. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1550. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_RW|WIA_PROP_LIST;
  1551. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1552. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.pList = (BYTE*)pProperties->pSupportedCompressionTypes;
  1553. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1554. pProperties->wpiItemDefaults[PropIndex].ValidVal.List.cNumList = pProperties->NumSupportedCompressionTypes;
  1555. PropIndex++;
  1556. // Initialize WIA_IPA_ITEM_FLAGS
  1557. pProperties->pszItemDefaults[PropIndex] = WIA_IPA_ITEM_FLAGS_STR;
  1558. pProperties->piItemDefaults [PropIndex] = WIA_IPA_ITEM_FLAGS;
  1559. pProperties->pvItemDefaults [PropIndex].lVal = WiaItemTypeImage|WiaItemTypeFile|WiaItemTypeDevice;
  1560. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1561. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1562. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1563. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_FLAG;
  1564. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1565. pProperties->wpiItemDefaults[PropIndex].ValidVal.Flag.Nom = pProperties->pvItemDefaults [PropIndex].lVal;
  1566. pProperties->wpiItemDefaults[PropIndex].ValidVal.Flag.ValidBits = WiaItemTypeImage|WiaItemTypeFile|WiaItemTypeDevice;
  1567. PropIndex++;
  1568. // Initialize WIA_IPS_PHOTOMETRIC_INTERP
  1569. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_PHOTOMETRIC_INTERP_STR;
  1570. pProperties->piItemDefaults [PropIndex] = WIA_IPS_PHOTOMETRIC_INTERP;
  1571. pProperties->pvItemDefaults [PropIndex].lVal = INITIAL_PHOTOMETRIC_INTERP;
  1572. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1573. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1574. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1575. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  1576. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1577. PropIndex++;
  1578. // Intialize WIA_IPS_WARM_UP_TIME_STR (NONE)
  1579. pProperties->pszItemDefaults[PropIndex] = WIA_IPS_WARM_UP_TIME_STR;
  1580. pProperties->piItemDefaults [PropIndex] = WIA_IPS_WARM_UP_TIME;
  1581. pProperties->pvItemDefaults [PropIndex].lVal = 10000;
  1582. pProperties->pvItemDefaults [PropIndex].vt = VT_I4;
  1583. pProperties->psItemDefaults [PropIndex].ulKind = PRSPEC_PROPID;
  1584. pProperties->psItemDefaults [PropIndex].propid = pProperties->piItemDefaults [PropIndex];
  1585. pProperties->wpiItemDefaults[PropIndex].lAccessFlags = WIA_PROP_READ|WIA_PROP_NONE;
  1586. pProperties->wpiItemDefaults[PropIndex].vt = pProperties->pvItemDefaults [PropIndex].vt;
  1587. PropIndex++;
  1588. return hr;
  1589. }
  1590. HRESULT CMicroDriverAPI::SetResolutionRestrictionString(TCHAR *szResolutions)
  1591. {
  1592. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  1593. WIALOG_NO_RESOURCE_ID,
  1594. WIALOG_LEVEL1,
  1595. "CMicroDriverAPI::SetResolutionRestrictionString");
  1596. //
  1597. // SBB - RAID 370299 - orenr - 2001/04/18 - Security fix -
  1598. // potential buffer overrun. Changed lstrcpy to use
  1599. // _tcsncpy instead.
  1600. //
  1601. ZeroMemory(m_szResolutions, sizeof(m_szResolutions));
  1602. _tcsncpy(m_szResolutions,
  1603. szResolutions,
  1604. (sizeof(m_szResolutions) / sizeof(TCHAR)) - 1);
  1605. #ifdef UNICODE
  1606. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("CMicroDriverAPI::SetResolutionRestrictionString, szResolutions = %ws",szResolutions));
  1607. #else
  1608. WIAS_LTRACE(m_pIWiaLog,WIALOG_NO_RESOURCE_ID,WIALOG_LEVEL2,("CMicroDriverAPI::SetResolutionRestrictionString, szResolutions = %s",szResolutions));
  1609. #endif
  1610. return S_OK;
  1611. }
  1612. HRESULT CMicroDriverAPI::SetScanMode(INT iScanMode)
  1613. {
  1614. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  1615. WIALOG_NO_RESOURCE_ID,
  1616. WIALOG_LEVEL1,
  1617. "SetScanMode");
  1618. HRESULT hr = S_OK;
  1619. VAL Value;
  1620. memset(&Value,0,sizeof(Value));
  1621. Value.pScanInfo = &m_ScanInfo;
  1622. Value.lVal = iScanMode;
  1623. hr = m_pMicroDriver->MicroEntry(CMD_SETSCANMODE,&Value);
  1624. if(FAILED(hr)){
  1625. if(E_NOTIMPL == hr){
  1626. hr = S_OK;
  1627. }
  1628. return hr;
  1629. }
  1630. return hr;
  1631. }
  1632. HRESULT CMicroDriverAPI::SetSTIDeviceHKEY(HKEY *pHKEY)
  1633. {
  1634. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  1635. WIALOG_NO_RESOURCE_ID,
  1636. WIALOG_LEVEL1,
  1637. "SetSTIDeviceHKEY");
  1638. HRESULT hr = S_OK;
  1639. VAL Value;
  1640. memset(&Value,0,sizeof(Value));
  1641. Value.pScanInfo = &m_ScanInfo;
  1642. Value.pHandle = (HANDLE*)pHKEY;
  1643. hr = m_pMicroDriver->MicroEntry(CMD_SETSTIDEVICEHKEY,&Value);
  1644. if(FAILED(hr)){
  1645. if(E_NOTIMPL == hr){
  1646. hr = S_OK;
  1647. }
  1648. return hr;
  1649. }
  1650. return hr;
  1651. }
  1652. HRESULT CMicroDriverAPI::GetSupportedFileFormats(GUID **ppguid, LONG *plNumSupportedFormats)
  1653. {
  1654. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  1655. WIALOG_NO_RESOURCE_ID,
  1656. WIALOG_LEVEL1,
  1657. "GetSupportedFileFormats");
  1658. HRESULT hr = S_OK;
  1659. *plNumSupportedFormats = 0;
  1660. *ppguid = NULL;
  1661. VAL Value;
  1662. memset(&Value,0,sizeof(Value));
  1663. Value.pScanInfo = &m_ScanInfo;
  1664. hr = m_pMicroDriver->MicroEntry(CMD_GETSUPPORTEDFILEFORMATS,&Value);
  1665. if(FAILED(hr)){
  1666. return hr;
  1667. }
  1668. *plNumSupportedFormats = Value.lVal;
  1669. *ppguid = Value.pGuid;
  1670. return hr;
  1671. }
  1672. HRESULT CMicroDriverAPI::GetSupportedMemoryFormats(GUID **ppguid, LONG *plNumSupportedFormats)
  1673. {
  1674. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  1675. WIALOG_NO_RESOURCE_ID,
  1676. WIALOG_LEVEL1,
  1677. "GetSupportedMemoryFormats");
  1678. HRESULT hr = S_OK;
  1679. *plNumSupportedFormats = 0;
  1680. *ppguid = NULL;
  1681. VAL Value;
  1682. memset(&Value,0,sizeof(Value));
  1683. Value.pScanInfo = &m_ScanInfo;
  1684. hr = m_pMicroDriver->MicroEntry(CMD_GETSUPPORTEDMEMORYFORMATS,&Value);
  1685. if(FAILED(hr)){
  1686. return hr;
  1687. }
  1688. *plNumSupportedFormats = Value.lVal;
  1689. *ppguid = Value.pGuid;
  1690. return hr;
  1691. }
  1692. HRESULT CMicroDriverAPI::IsColorDataBGR(BOOL *pbBGR)
  1693. {
  1694. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  1695. WIALOG_NO_RESOURCE_ID,
  1696. WIALOG_LEVEL1,
  1697. "IsColorDataBGR");
  1698. HRESULT hr = S_OK;
  1699. // WIA_ORDER_RGB 0
  1700. // WIA_ORDER_BGR 1
  1701. *pbBGR = (m_ScanInfo.RawPixelOrder == WIA_ORDER_BGR);
  1702. return hr;
  1703. }
  1704. HRESULT CMicroDriverAPI::IsAlignmentNeeded(BOOL *pbALIGN)
  1705. {
  1706. CWiaLogProc WIAS_LOGPROC(m_pIWiaLog,
  1707. WIALOG_NO_RESOURCE_ID,
  1708. WIALOG_LEVEL1,
  1709. "IsAlignmentNeeded");
  1710. HRESULT hr = S_OK;
  1711. *pbALIGN = m_ScanInfo.bNeedDataAlignment;
  1712. return hr;
  1713. }