Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

CScannerList Class Reference

#include <profile.h>

Inheritance diagram for CScannerList:

CDeviceList List of all members.

Public Member Functions

 CScannerList ()
 ~CScannerList ()
virtual unsigned Count ()
virtual CStringDeviceName (unsigned u)
virtual CStringDisplayName (unsigned u)
virtual void Enumerate ()
virtual BOOL IsValidDeviceName (LPCTSTR lpstr)

Private Attributes

CStringArray m_csaDeviceNames
CStringArray m_csaDisplayNames

Constructor & Destructor Documentation

CScannerList::CScannerList  )  [inline]
 

Definition at line 124 of file icmui/profile.h.

00124 {}

CScannerList::~CScannerList  )  [inline]
 

Definition at line 125 of file icmui/profile.h.

00125 {}


Member Function Documentation

virtual unsigned CScannerList::Count  )  [inline, virtual]
 

Reimplemented from CDeviceList.

Definition at line 127 of file icmui/profile.h.

References CStringArray::Count(), and m_csaDeviceNames.

Referenced by CICMUserInterface::AddScannerTab(), CAllDeviceList::Enumerate(), and IsValidDeviceName().

00127 { return m_csaDeviceNames.Count(); }

virtual CString& CScannerList::DeviceName unsigned  u  )  [inline, virtual]
 

Reimplemented from CDeviceList.

Definition at line 128 of file icmui/profile.h.

References DeviceName(), and m_csaDeviceNames.

Referenced by CICMUserInterface::AddScannerTab(), DeviceName(), and CAllDeviceList::Enumerate().

00128 { return m_csaDeviceNames[u]; }

virtual CString& CScannerList::DisplayName unsigned  u  )  [inline, virtual]
 

Reimplemented from CDeviceList.

Definition at line 129 of file icmui/profile.h.

References DisplayName(), and m_csaDisplayNames.

Referenced by DisplayName(), and CAllDeviceList::Enumerate().

00129 { return m_csaDisplayNames[u]; }

void CScannerList::Enumerate  )  [virtual]
 

Reimplemented from CDeviceList.

Definition at line 240 of file profile.cpp.

References CStringArray::Add(), BOOL, DWORD, gszStiCreateInstance, gszStiDll, m_csaDeviceNames, m_csaDisplayNames, NULL, PFNSTICREATEINSTANCE, PSTI, PSTI_DEVICE_INFORMATION, _STI_DEVICE_INFORMATIONW::pszLocalName, STI_VERSION, _STI_DEVICE_INFORMATIONW::szDeviceInternalName, and szName.

Referenced by CICMUserInterface::AddScannerTab(), CAllDeviceList::Enumerate(), and IsValidDeviceName().

00240 { 00241 00242 PFNSTICREATEINSTANCE pStiCreateInstance; 00243 PSTI pSti = NULL; 00244 PSTI_DEVICE_INFORMATION pDevInfo; 00245 PVOID pBuffer = NULL; 00246 HINSTANCE hModule; 00247 HRESULT hres; 00248 DWORD i, dwItemsReturned; 00249 #ifndef UNICODE 00250 char szName[256]; 00251 #endif 00252 00253 if (!(hModule = LoadLibrary(gszStiDll))) 00254 { 00255 _RPTF1(_CRT_WARN, "Error loading sti.dll: %d\n", 00256 GetLastError()); 00257 return; 00258 } 00259 00260 if (!(pStiCreateInstance = (PFNSTICREATEINSTANCE)GetProcAddress(hModule, gszStiCreateInstance))) 00261 { 00262 _RPTF0(_CRT_WARN, "Error getting proc StiCreateInstance\n"); 00263 goto EndEnumerate; 00264 } 00265 00266 hres = (*pStiCreateInstance)(GetModuleHandle(NULL), STI_VERSION, &pSti, NULL); 00267 00268 if (FAILED(hres)) 00269 { 00270 _RPTF1(_CRT_WARN, "Error creating sti instance: %d\n", hres); 00271 goto EndEnumerate; 00272 } 00273 00274 hres = pSti->GetDeviceList(0, 0, &dwItemsReturned, &pBuffer); 00275 00276 if (FAILED(hres) || !pBuffer) 00277 { 00278 _RPTF0(_CRT_WARN, "Error getting scanner devices\n"); 00279 goto EndEnumerate; 00280 } 00281 00282 pDevInfo = (PSTI_DEVICE_INFORMATION) pBuffer; 00283 00284 for (i=0; i<dwItemsReturned; i++, pDevInfo++) 00285 { 00286 #ifndef UNICODE 00287 DWORD dwLen; // length of Ansi string 00288 BOOL bUsedDefaultChar; 00289 00290 dwLen = (lstrlenW(pDevInfo->pszLocalName) + 1) * sizeof(char); 00291 00292 // 00293 // Convert Unicode name to Ansi 00294 // 00295 if (WideCharToMultiByte(CP_ACP, 0, pDevInfo->szDeviceInternalName, -1, szName, 00296 dwLen, NULL, &bUsedDefaultChar) && ! bUsedDefaultChar) 00297 { 00298 m_csaDeviceNames.Add(szName); 00299 } 00300 else 00301 { 00302 _RPTF0(_CRT_WARN, "Error converting internalName to Unicode name\n"); 00303 } 00304 00305 if (WideCharToMultiByte(CP_ACP, 0, pDevInfo->pszLocalName, -1, szName, 00306 dwLen, NULL, &bUsedDefaultChar) && ! bUsedDefaultChar) 00307 { 00308 m_csaDisplayNames.Add(szName); 00309 } 00310 else 00311 { 00312 _RPTF0(_CRT_WARN, "Error converting deviceName to Unicode name\n"); 00313 } 00314 00315 #else 00316 m_csaDeviceNames.Add(pDevInfo->szDeviceInternalName); 00317 m_csaDisplayNames.Add(pDevInfo->pszLocalName); 00318 #endif 00319 } 00320 00321 EndEnumerate: 00322 if (pBuffer) 00323 { 00324 LocalFree(pBuffer); 00325 } 00326 00327 if (pSti) 00328 { 00329 pSti->Release(); 00330 } 00331 00332 if (hModule) 00333 { 00334 FreeLibrary(hModule); 00335 } 00336 00337 return; 00338 }

BOOL CScannerList::IsValidDeviceName LPCTSTR  lpstr  )  [virtual]
 

Reimplemented from CDeviceList.

Definition at line 342 of file profile.cpp.

References BOOL, Count(), Enumerate(), FALSE, IsValidDeviceName(), and m_csaDeviceNames.

Referenced by IsValidDeviceName().

00342 { 00343 00344 if (!lpstrRef) return FALSE; 00345 00346 if (!Count()) 00347 Enumerate(); 00348 00349 for (unsigned u = 0; u < Count(); u++) 00350 if (!lstrcmpi(m_csaDeviceNames[u], lpstrRef)) 00351 break; 00352 00353 return u < Count(); 00354 }


Member Data Documentation

CStringArray CScannerList::m_csaDeviceNames [private]
 

Definition at line 120 of file icmui/profile.h.

Referenced by Count(), DeviceName(), Enumerate(), and IsValidDeviceName().

CStringArray CScannerList::m_csaDisplayNames [private]
 

Definition at line 121 of file icmui/profile.h.

Referenced by DisplayName(), and Enumerate().


The documentation for this class was generated from the following files:
Generated on Sat May 15 19:46:28 2004 for test by doxygen 1.3.7