TWain 在 Qt4 中的調用方法

一、開發環境this

Windows7_sp1_x64   Qt4.7.4 + mingw32  twain_32.dll (1.7.1.3)spa

二、經常使用縮寫code

DSM: Data Source Manager  數據源管理器 blog

DS: Data Source  數據源開發

DSM_Entry: DSM調用入口 io

TW_UINT16 FAR PASCAL DSM_Entry(   pTW_IDENTITY pOrigin,    // Source of message
  pTW_IDENTITY pDest,      // Destination of message
  TW_UINT32 DG,          // Data group ID: DG_xxxx; DG_CONTROL,DG_IMAGE,DG_AUDIO
  TW_UINT16 DAT,         // Data argument type: DAT_xxxx; DAT_IDENTITY ...
  TW_UINT16 MSG,         // Message ID: MSG_xxxx; MSG_GET,MSG_SET ...
  TW_MEMREF pData         // Pointer to data
);

三、調用實現class

3.0 加載 TWAIN_32.DLL,並獲取 DSM_Entry數據

HINSTANCE m_hTwainDLL = LoadLibrary(L"TWAIN_32.DLL");

DSMENTRYPROC m_pDSMProc = (DSMENTRYPROC)GetProcAddress(m_hTwainDLL, "DSM_Entry");

3.1 打開 DSMmargin

MSG_PROCESSEVENTdi

HWND hWnd = this->WinId();
TW_IDENTITY m_AppId;
BOOL m_bDSMOpen = DSM_Entry(&m_AppId,NULL,DG_CONTROL,DAT_PARENT,MSG_OPENDSM,(TW_MEMREF)&hWnd);

3.2 選擇 DS

TW_IDENTITY m_Source;
BOOL m_bDSSelect = DSM_Entry(&m_AppId,NULL,DG_CONTROL,DAT_IDENTITY,MSG_USERSELECT,&m_Source);
BOOL m_bDSSelect = DSM_Entry(&m_AppId,NULL,DG_CONTROL,DAT_IDENTITY,MSG_GETDEFAULT,&m_Source);

 

3.3 打開 DS

BOOL m_bDSOpen = DSM_Entry(&m_AppId,NULL,DG_CONTROL,DAT_IDENTITY,MSG_OPENDS,(TW_MEMREF)&m_Source);

 

3.4 設置參數

MSG_SET

3.5 顯示掃描界面

MSG_ENABLEDS 

3.6 獲取圖像

MSG_XFERREADY

DAT_SETUPFILEXFER 

DAT_IMAGEFILEXFER 

3.7 關閉掃描界面

MSG_CLOSEDSREQ 

MSG_CLOSEDSOK 

MSG_DISABLEDS

3.8 關閉 DS

MSG_CLOSEDS

3.9 關閉 DSM

MSG_CLOSEDSM

相關文章
相關標籤/搜索