-
Notifications
You must be signed in to change notification settings - Fork 0
/
ErrorHandler.h
75 lines (54 loc) · 2.6 KB
/
ErrorHandler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef __WIA_ERRORHANDLER_SAMPLE
//==========================================================================
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//--------------------------------------------------------------------------
//------------------------------------------------------------
//Please read the ReadME.txt which explains the purpose of the
//sample.
//-------------------------------------------------------------
#define __WIA_ERRORHANDLER_SAMPLE
#include "utils.h"
#define MAX_TEMP_PATH 1024
#define MAX_FILENAME_LENGTH 1024
class CWiaTransferCallback : public IWiaTransferCallback,public IWiaAppErrorHandler
{
private:
ULONG m_cRef; //for reference counting
long m_lPageCount; //page counting for feeder item
BSTR m_bstrFileExtension; //file extension to be appended to the download file
BOOL m_bFeederTransfer; //flag indicating whether download is from feeder item
BSTR m_bstrDirectoryName; //download directory
BSTR m_ItemName; // item name
TCHAR m_szFileName[MAX_FILENAME_LENGTH]; //download file
public:
//
// Constructor and destructor
//
CWiaTransferCallback();
virtual ~CWiaTransferCallback();
// To Initialize the download directory , file extension and bFeederTransfer(which indicates whether download is from feeder item)
HRESULT InitializeCallback(TCHAR* bstrDirectoryName, BSTR bstrExt, BOOL bFeederTransfer);
// IUnknown functions
HRESULT CALLBACK QueryInterface( REFIID riid, void **ppvObject );
ULONG CALLBACK AddRef();
ULONG CALLBACK Release();
// IWiaTransferCallback functions
HRESULT STDMETHODCALLTYPE TransferCallback(LONG lFlags,WiaTransferParams *pWiaTransferParams);
HRESULT STDMETHODCALLTYPE GetNextStream(LONG lFlags, BSTR bstrItemName, BSTR bstrFullItemName, IStream **ppDestination);
// IWiaAppErrorHandler functions
HRESULT STDMETHODCALLTYPE ReportStatus(LONG lFlags,IWiaItem2* pWiaItem2,HRESULT hrStatus,LONG lPercentComplete);
HRESULT STDMETHODCALLTYPE GetWindow( HWND *phwnd );
void RotateAndCropJpeg(BSTR m_bstrDirectoryName, TCHAR* m_szFileName);
};
HRESULT DownloadItem(IWiaItem2* pWiaItem2);
HRESULT EnumerateAndDownloadItems( IWiaItem2 *pIWiaItem2 );
HRESULT EnumerateWiaDevices( IWiaDevMgr2 *pWiaDevMgr2 );
bool consoleHandler(int signal);
#endif