forked from microsoft/mfcmapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StdAfx.h
501 lines (419 loc) · 14.7 KB
/
StdAfx.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
#pragma once
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#pragma warning(push)
#pragma warning(disable: 4995)
#include <cstdio>
#include <cstring>
#include <cwchar>
#pragma warning(pop)
#include <list>
#include <algorithm>
// Speed up our string conversions for output
#ifdef MRMAPI
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#include <sal.h>
// A bug in annotations in shobjidl.h forces us to disable 6387 to include afxwin.h
#pragma warning(push)
#pragma warning(disable:6387)
#include <afxwin.h> // MFC core and standard components
#pragma warning(pop)
#include <afxcmn.h> // MFC support for Windows Common Controls
#pragma warning(push)
#pragma warning(disable: 4091)
#include <shlobj.h>
#pragma warning(pop)
// Safe String handling header
#include <strsafe.h>
// Fix a build issue with a few versions of the MAPI headers
#if !defined(FREEBUFFER_DEFINED)
typedef ULONG(STDAPICALLTYPE FREEBUFFER)(
LPVOID lpBuffer
);
#define FREEBUFFER_DEFINED
#endif
#include <MapiX.h>
#include <MapiUtil.h>
#include <MAPIform.h>
#include <MAPIWz.h>
#include <MAPIHook.h>
#include <MSPST.h>
#include <edkmdb.h>
#include <exchform.h>
#include <EMSAbTag.h>
#include <IMessage.h>
#include <edkguid.h>
#include <tnef.h>
#include <mapiaux.h>
#include <aclui.h>
#include <uxtheme.h>
// there's an odd conflict with mimeole.h and richedit.h - this should fix it
#ifdef UNICODE
#undef CHARFORMAT
#endif
#include <mimeole.h>
#ifdef UNICODE
#undef CHARFORMAT
#define CHARFORMAT CHARFORMATW
#endif
#include <Res/Resource.h> // main symbols
#include <IO/MFCOutput.h>
#include <IO/Registry.h>
#include <Interpret/InterpretProp.h>
#include <IO/Error.h>
#include "MFCMAPI.h"
struct TagNames
{
ULONG ulMatchingTableColumn;
UINT uidName;
};
class CAdviseSink;
// Macros to assist in OnInitMenu
#define CHECK(state) ((state)?MF_CHECKED:MF_UNCHECKED)
#define DIM(state) ((state)?MF_ENABLED:MF_GRAYED)
#define DIMMSOK(iNumSelected) ((iNumSelected>=1)?MF_ENABLED:MF_GRAYED)
#define DIMMSNOK(iNumSelected) ((iNumSelected==1)?MF_ENABLED:MF_GRAYED)
// Various flags gleaned from product documentation and KB articles
// http://msdn2.microsoft.com/en-us/library/ms526744.aspx
#define STORE_HTML_OK ((ULONG) 0x00010000)
#define STORE_ANSI_OK ((ULONG) 0x00020000)
#define STORE_LOCALSTORE ((ULONG) 0x00080000)
// http://msdn2.microsoft.com/en-us/library/ms531462.aspx
#define ATT_INVISIBLE_IN_HTML ((ULONG) 0x00000001)
#define ATT_INVISIBLE_IN_RTF ((ULONG) 0x00000002)
#define ATT_MHTML_REF ((ULONG) 0x00000004)
// http://msdn2.microsoft.com/en-us/library/ms527629.aspx
#define MSGFLAG_ORIGIN_X400 ((ULONG) 0x00001000)
#define MSGFLAG_ORIGIN_INTERNET ((ULONG) 0x00002000)
#define MSGFLAG_ORIGIN_MISC_EXT ((ULONG) 0x00008000)
#define MSGFLAG_OUTLOOK_NON_EMS_XP ((ULONG) 0x00010000)
// http://msdn2.microsoft.com/en-us/library/ms528848.aspx
#define MSGSTATUS_DRAFT ((ULONG) 0x00000100)
#define MSGSTATUS_ANSWERED ((ULONG) 0x00000200)
#define ENCODING_PREFERENCE ((ULONG) 0x00020000)
#define ENCODING_MIME ((ULONG) 0x00040000)
#define BODY_ENCODING_HTML ((ULONG) 0x00080000)
#define BODY_ENCODING_TEXT_AND_HTML ((ULONG) 0x00100000)
#define MAC_ATTACH_ENCODING_UUENCODE ((ULONG) 0x00200000)
#define MAC_ATTACH_ENCODING_APPLESINGLE ((ULONG) 0x00400000)
#define MAC_ATTACH_ENCODING_APPLEDOUBLE ((ULONG) 0x00600000)
// Custom messages - used to ensure actions occur on the right threads.
// Used by CAdviseSink:
#define WM_MFCMAPI_ADDITEM WM_APP+1
#define WM_MFCMAPI_DELETEITEM WM_APP+2
#define WM_MFCMAPI_MODIFYITEM WM_APP+3
#define WM_MFCMAPI_REFRESHTABLE WM_APP+4
// Used by DwThreadFuncLoadTable
#define WM_MFCMAPI_THREADADDITEM WM_APP+5
#define WM_MFCMAPI_UPDATESTATUSBAR WM_APP+6
#define WM_MFCMAPI_CLEARSINGLEMAPIPROPLIST WM_APP+7
// Used by CSingleMAPIPropListCtrl and CSortHeader
#define WM_MFCMAPI_SAVECOLUMNORDERHEADER WM_APP+10
#define WM_MFCMAPI_SAVECOLUMNORDERLIST WM_APP+11
// Used by CContentsTableDlg
#define WM_MFCMAPI_RESETCOLUMNS WM_APP+12
// Definitions for WrapCompressedRTFStreamEx in param for WrapCompressedRTFStreamEX
// http://msdn2.microsoft.com/en-us/library/bb905293.aspx
struct RTF_WCSINFO {
ULONG size; // Size of the structure
ULONG ulFlags;
/****** MAPI_MODIFY ((ULONG) 0x00000001) above */
/****** STORE_UNCOMPRESSED_RTF ((ULONG) 0x00008000) above */
/****** MAPI_NATIVE_BODY ((ULONG) 0x00010000) mapidefs.h Only used for reading*/
ULONG ulInCodePage; // Codepage of the message, used when passing MAPI_NATIVE_BODY, ignored otherwise
ULONG ulOutCodePage; // Codepage of the Returned Stream, used when passing MAPI_NATIVE_BODY, ignored otherwise
};
// out param type information for WrapCompressedRTFStreamEX
// http://msdn2.microsoft.com/en-us/library/bb905294.aspx
struct RTF_WCSRETINFO {
ULONG size; // Size of the structure
ULONG ulStreamFlags;
/****** MAPI_NATIVE_BODY_TYPE_RTF ((ULONG) 0x00000001) mapidefs.h */
/****** MAPI_NATIVE_BODY_TYPE_HTML ((ULONG) 0x00000002) mapidefs.h */
/****** MAPI_NATIVE_BODY_TYPE_PLAINTEXT ((ULONG) 0x00000004) mapidefs.h */
};
#define MAPI_NATIVE_BODY 0x00010000
/* out param type infomation for WrapCompressedRTFStreamEx */
#define MAPI_NATIVE_BODY_TYPE_RTF 0x00000001
#define MAPI_NATIVE_BODY_TYPE_HTML 0x00000002
#define MAPI_NATIVE_BODY_TYPE_PLAINTEXT 0x00000004
// For EditSecurity
typedef bool (STDAPICALLTYPE EDITSECURITY)
(
HWND hwndOwner,
LPSECURITYINFO psi
);
typedef EDITSECURITY* LPEDITSECURITY;
// For StgCreateStorageEx
typedef HRESULT(STDAPICALLTYPE STGCREATESTORAGEEX)
(
IN const WCHAR* pwcsName,
IN DWORD grfMode,
IN DWORD stgfmt, // enum
IN DWORD grfAttrs, // reserved
IN STGOPTIONS * pStgOptions,
IN void * reserved,
IN REFIID riid,
OUT void ** ppObjectOpen);
typedef STGCREATESTORAGEEX* LPSTGCREATESTORAGEEX;
// For Themes
typedef HTHEME(STDMETHODCALLTYPE OPENTHEMEDATA)
(
HWND hwnd,
LPCWSTR pszClassList);
typedef OPENTHEMEDATA* LPOPENTHEMEDATA;
typedef HTHEME(STDMETHODCALLTYPE CLOSETHEMEDATA)
(
HTHEME hTheme);
typedef CLOSETHEMEDATA* LPCLOSETHEMEDATA;
typedef HRESULT(STDMETHODCALLTYPE GETTHEMEMARGINS)
(
HTHEME hTheme,
OPTIONAL HDC hdc,
int iPartId,
int iStateId,
int iPropId,
OPTIONAL RECT *prc,
OUT MARGINS *pMargins);
typedef GETTHEMEMARGINS* LPGETTHEMEMARGINS;
typedef HRESULT(STDMETHODCALLTYPE SETWINDOWTHEME)
(
__in HWND hwnd,
__in LPCWSTR pszSubAppName,
__in LPCWSTR pszSubIdList
);
typedef SETWINDOWTHEME* LPSETWINDOWTHEME;
typedef int (STDMETHODCALLTYPE GETTHEMESYSSIZE)
(
HTHEME hTheme,
int iSizeID
);
typedef GETTHEMESYSSIZE* LPGETTHEMESYSSIZE;
typedef HRESULT(STDMETHODCALLTYPE MSIPROVIDEQUALIFIEDCOMPONENT)
(
LPCWSTR szCategory,
LPCWSTR szQualifier,
DWORD dwInstallMode,
LPWSTR lpPathBuf,
LPDWORD pcchPathBuf
);
typedef MSIPROVIDEQUALIFIEDCOMPONENT* LPMSIPROVIDEQUALIFIEDCOMPONENT;
typedef HRESULT(STDMETHODCALLTYPE MSIGETFILEVERSION)
(
LPCWSTR szFilePath,
LPWSTR lpVersionBuf,
LPDWORD pcchVersionBuf,
LPWSTR lpLangBuf,
LPDWORD pcchLangBuf
);
typedef MSIGETFILEVERSION* LPMSIGETFILEVERSION;
typedef HRESULT(STDMETHODCALLTYPE SHGETPROPERTYSTOREFORWINDOW)
(
HWND hwnd,
REFIID riid,
void** ppv
);
typedef SHGETPROPERTYSTOREFORWINDOW* LPSHGETPROPERTYSTOREFORWINDOW;
// http://msdn.microsoft.com/en-us/library/office/dn433223.aspx
#pragma pack(4)
struct CONTAB_ENTRYID
{
BYTE abFlags[4];
MAPIUID muid;
ULONG ulVersion;
ULONG ulType;
ULONG ulIndex;
ULONG cbeid;
BYTE abeid[1];
};
typedef CONTAB_ENTRYID* LPCONTAB_ENTRYID;
#pragma pack()
// http://msdn.microsoft.com/en-us/library/office/dn433221.aspx
#pragma pack(4)
struct DIR_ENTRYID
{
BYTE abFlags[4];
MAPIUID muid;
ULONG ulVersion;
ULONG ulType;
MAPIUID muidID;
};
typedef DIR_ENTRYID* LPDIR_ENTRYID;
#pragma pack()
// http://msdn2.microsoft.com/en-us/library/bb820951.aspx
#define MAPI_IPROXYSTOREOBJECT_METHODS(IPURE) \
MAPIMETHOD(PlaceHolder1) \
() IPURE; \
MAPIMETHOD(UnwrapNoRef) \
(LPVOID *ppvObject) IPURE; \
MAPIMETHOD(PlaceHolder2) \
() IPURE;
DECLARE_MAPI_INTERFACE_(IProxyStoreObject, IUnknown)
{
BEGIN_INTERFACE
MAPI_IUNKNOWN_METHODS(PURE)
MAPI_IPROXYSTOREOBJECT_METHODS(PURE)
};
#ifndef MAPI_IMAPICLIENTSHUTDOWN_METHODS
// http://blogs.msdn.com/stephen_griffin/archive/2009/03/03/fastest-shutdown-in-the-west.aspx
DECLARE_MAPI_INTERFACE_PTR(IMAPIClientShutdown, LPMAPICLIENTSHUTDOWN);
#define MAPI_IMAPICLIENTSHUTDOWN_METHODS(IPURE) \
MAPIMETHOD(QueryFastShutdown) \
(THIS) IPURE; \
MAPIMETHOD(NotifyProcessShutdown) \
(THIS) IPURE; \
MAPIMETHOD(DoFastShutdown) \
(THIS) IPURE;
DECLARE_MAPI_INTERFACE_(IMAPIClientShutdown, IUnknown)
{
BEGIN_INTERFACE
MAPI_IUNKNOWN_METHODS(PURE)
MAPI_IMAPICLIENTSHUTDOWN_METHODS(PURE)
};
#define _IID_IMAPIClientShutdown_MISSING_IN_HEADER
#endif // MAPI_IMAPICLIENTSHUTDOWN_METHODS
#ifndef MAPI_IMAPIPROVIDERSHUTDOWN_METHODS
/* IMAPIProviderShutdown Interface --------------------------------------- */
DECLARE_MAPI_INTERFACE_PTR(IMAPIProviderShutdown, LPMAPIPROVIDERSHUTDOWN);
#define MAPI_IMAPIPROVIDERSHUTDOWN_METHODS(IPURE) \
MAPIMETHOD(QueryFastShutdown) \
(THIS) IPURE; \
MAPIMETHOD(NotifyProcessShutdown) \
(THIS) IPURE; \
MAPIMETHOD(DoFastShutdown) \
(THIS) IPURE;
DECLARE_MAPI_INTERFACE_(IMAPIProviderShutdown, IUnknown)
{
BEGIN_INTERFACE
MAPI_IUNKNOWN_METHODS(PURE)
MAPI_IMAPIPROVIDERSHUTDOWN_METHODS(PURE)
};
#endif // MAPI_IMAPIPROVIDERSHUTDOWN_METHODS
// for CompareStrings
static DWORD g_lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
// In case we are compiling against an older version of headers
#if !defined ACLTABLE_FREEBUSY
#define ACLTABLE_FREEBUSY ((ULONG) 0x00000002)
#endif // ACLTABLE_FREEBUSY
#if !defined frightsFreeBusySimple
#define frightsFreeBusySimple 0x0000800L
#endif // frightsFreeBusySimple
#if !defined frightsFreeBusyDetailed
#define frightsFreeBusyDetailed 0x0001000L
#endif // frightsFreeBusyDetailed
#if !defined fsdrightFreeBusySimple
#define fsdrightFreeBusySimple 0x00000001
#endif // fsdrightFreeBusySimple
#if !defined fsdrightFreeBusyDetailed
#define fsdrightFreeBusyDetailed 0x00000002
#endif // fsdrightFreeBusyDetailed
// http://msdn2.microsoft.com/en-us/library/bb820933.aspx
#define MAPI_IATTACHMENTSECURITY_METHODS(IPURE) \
MAPIMETHOD(IsAttachmentBlocked) \
(LPCWSTR pwszFileName, BOOL *pfBlocked) IPURE;
DECLARE_MAPI_INTERFACE_(IAttachmentSecurity, IUnknown)
{
BEGIN_INTERFACE
MAPI_IUNKNOWN_METHODS(PURE)
MAPI_IATTACHMENTSECURITY_METHODS(PURE)
};
// http://msdn2.microsoft.com/en-us/library/bb820937.aspx
#define STORE_PUSHER_OK ((ULONG) 0x00800000)
#define fnevIndexing ((ULONG) 0x00010000)
/* Indexing notifications (used for FTE related communications) */
/* Shares EXTENDED_NOTIFICATION to pass structures below, */
/* but NOTIFICATION type will be fnevIndexing */
// Stores that are pusher enabled (PR_STORE_SUPPORT_MASK contains STORE_PUSHER_OK)
// are required to send notifications regarding the process that is pushing.
#define INDEXING_SEARCH_OWNER ((ULONG) 0x00000001)
struct INDEX_SEARCH_PUSHER_PROCESS
{
DWORD dwPID; // PID for process pushing
};
// http://blogs.msdn.com/stephen_griffin/archive/2006/05/11/595338.aspx
#define STORE_FULLTEXT_QUERY_OK ((ULONG) 0x02000000)
#define STORE_FILTER_SEARCH_OK ((ULONG) 0x04000000)
// Will match prefix on words instead of the whole prop value
#define FL_PREFIX_ON_ANY_WORD 0x00000010
// Phrase match means the words have to be exactly matched and the
// sequence matters. This is different than FL_FULLSTRING because
// it doesn't require the whole property value to be the same. One
// term exactly matching a term in the property value is enough for
// a match even if there are more terms in the property.
#define FL_PHRASE_MATCH 0x00000020
// http://msdn2.microsoft.com/en-us/library/bb905283.aspx
#define dispidFormStorage 0x850F
#define dispidPageDirStream 0x8513
#define dispidFormPropStream 0x851B
#define dispidPropDefStream 0x8540
#define dispidScriptStream 0x8541
#define dispidCustomFlag 0x8542
#define INSP_ONEOFFFLAGS 0xD000000
#define INSP_PROPDEFINITION 0x2000000
// Sometimes IExchangeManageStore5 is in edkmdb.h, sometimes it isn't
#ifndef EXCHANGE_IEXCHANGEMANAGESTORE5_METHODS
#define USES_IID_IExchangeManageStore5
/*------------------------------------------------------------------------
*
* 'IExchangeManageStore5' Interface Declaration
*
* Used for store management functions.
*
*-----------------------------------------------------------------------*/
#define EXCHANGE_IEXCHANGEMANAGESTORE5_METHODS(IPURE) \
MAPIMETHOD(GetMailboxTableEx) \
(THIS_ LPSTR lpszServerName, \
LPGUID lpguidMdb, \
LPMAPITABLE* lppTable, \
ULONG ulFlags, \
UINT uOffset) IPURE; \
MAPIMETHOD(GetPublicFolderTableEx) \
(THIS_ LPSTR lpszServerName, \
LPGUID lpguidMdb, \
LPMAPITABLE* lppTable, \
ULONG ulFlags, \
UINT uOffset) IPURE; \
#undef INTERFACE
#define INTERFACE IExchangeManageStore5
DECLARE_MAPI_INTERFACE_(IExchangeManageStore5, IUnknown)
{
MAPI_IUNKNOWN_METHODS(PURE)
EXCHANGE_IEXCHANGEMANAGESTORE_METHODS(PURE)
EXCHANGE_IEXCHANGEMANAGESTORE2_METHODS(PURE)
EXCHANGE_IEXCHANGEMANAGESTORE3_METHODS(PURE)
EXCHANGE_IEXCHANGEMANAGESTORE4_METHODS(PURE)
EXCHANGE_IEXCHANGEMANAGESTORE5_METHODS(PURE)
};
#undef IMPL
#define IMPL
DECLARE_MAPI_INTERFACE_PTR(IExchangeManageStore5, LPEXCHANGEMANAGESTORE5);
#endif // #ifndef EXCHANGE_IEXCHANGEMANAGESTORE5_METHODS
#define EXCHANGE_IEXCHANGEMANAGESTOREEX_METHODS(IPURE) \
MAPIMETHOD(CreateStoreEntryID2) \
(THIS_ ULONG cValues, \
LPSPropValue lpPropArray, \
ULONG ulFlags, \
ULONG* lpcbEntryID, \
LPENTRYID * lppEntryID) IPURE;
#undef INTERFACE
#define INTERFACE IExchangeManageStoreEx
DECLARE_MAPI_INTERFACE_(IExchangeManageStoreEx, IUnknown)
{
MAPI_IUNKNOWN_METHODS(PURE)
EXCHANGE_IEXCHANGEMANAGESTORE_METHODS(PURE)
EXCHANGE_IEXCHANGEMANAGESTOREEX_METHODS(PURE)
};
#undef IMPL
#define IMPL
DECLARE_MAPI_INTERFACE_PTR(IExchangeManageStoreEx, LPEXCHANGEMANAGESTOREEX);
#define CbNewROWLIST(_centries) (offsetof(ROWLIST,aEntries) + \
(_centries)*sizeof(ROWENTRY))
#define MAXNewROWLIST (ULONG_MAX-offsetof(ROWLIST,aEntries))/sizeof(ROWENTRY)
#define MAXMessageClassArray (ULONG_MAX - offsetof(SMessageClassArray, aMessageClass))/sizeof(LPCSTR)
#define MAXNewADRLIST (ULONG_MAX - offsetof(ADRLIST, aEntries))/sizeof(ADRENTRY)
const WORD TZRULE_FLAG_RECUR_CURRENT_TZREG = 0x0001; // see dispidApptTZDefRecur
const WORD TZRULE_FLAG_EFFECTIVE_TZREG = 0x0002;
// http://blogs.msdn.com/stephen_griffin/archive/2007/03/19/mapi-and-exchange-2007.aspx
#define CONNECT_IGNORE_NO_PF ((ULONG)0x8000)
#define TABLE_SORT_CATEG_MAX ((ULONG) 0x00000004)
#define TABLE_SORT_CATEG_MIN ((ULONG) 0x00000008)