|
|
|
1 |
|
/* |
2 |
|
* M A P I W I N . H |
3 |
|
* |
4 |
|
* Definitions used by the MAPI Development Team to aid in |
5 |
|
* developing single-source service providers that run on |
6 |
|
* both WIN32 and WIN16 platforms. |
7 |
|
* There are three sections. |
8 |
|
* |
9 |
|
* The first section defines how to call something that |
10 |
|
* is available by different methods in WIN16 vs. WIN32. |
11 |
|
* As such, they are totally new mechanisms. |
12 |
|
* |
13 |
|
* The second section establishes things that are available |
14 |
|
* AS-IS in one environment but we have to define for the |
15 |
|
* other environment. |
16 |
|
* |
17 |
|
* The third section simply defines a few conventions |
18 |
|
* (simplifications) for common operations. |
19 |
|
* |
20 |
|
* Copyright 1986-1999 Microsoft Corporation. All Rights Reserved. |
21 |
|
*/ |
22 |
|
|
23 |
|
/* |
24 |
|
* Routines are included in the first section to manage per-instance |
25 |
|
* global variables for DLLs. They assume that all of the DLL's |
26 |
|
* per-instance global variables live in a single block of memory. |
27 |
|
* Functions are provided to install and retrieve the correct block of |
28 |
|
* memory for the current instance. |
29 |
|
* |
30 |
|
* There are only two functions: |
31 |
|
* |
32 |
|
* PvGetInstanceGlobals Call this to get the address of the |
33 |
|
* per-instance globals structure. |
34 |
|
* ScSetinstanceGlobals Call this to install the |
35 |
|
* per-instance globals structure. It |
36 |
|
* may fail if the number of instances |
37 |
|
* exceeds a certain limit. |
38 |
|
* |
39 |
|
* The caller is free to choose the name, size, and allocation |
40 |
|
* method of the per-instance global variables structure. |
41 |
|
* |
42 |
|
* The WIN32 implementation uses a pointer in the DLL's data |
43 |
|
* segment. This assumes that the DLL gets a separate instance |
44 |
|
* of the default data segment per calling process. |
45 |
|
* |
46 |
|
* The WIN16 implementation uses a fixed array of pointers and a |
47 |
|
* matching fixed array of keys unique to the calling process. |
48 |
|
*/ |
49 |
|
|
50 |
|
/* |
51 |
|
* The second section consists largely of Win32 file I/O functions |
52 |
|
* that are not supported under Win16. These functions are |
53 |
|
* implemented in mapiwin.c, using DOS calls. Most have limitations |
54 |
|
* relative to their Win32 counterparts, which are spelled out in |
55 |
|
* the comments to the source code. |
56 |
|
*/ |
57 |
|
|
58 |
|
#ifndef __MAPIWIN_H__ |
59 |
|
#define __MAPIWIN_H__ |
60 |
|
|
61 |
|
#if _MSC_VER > 1000 |
62 |
|
#pragma once |
63 |
|
#endif |
64 |
|
|
65 |
|
#if defined (WIN32) && !defined (_WIN32) |
66 |
|
#define _WIN32 |
67 |
|
#endif |
68 |
|
|
69 |
|
#include "mapinls.h" |
70 |
|
|
71 |
|
#ifdef __cplusplus |
72 |
|
extern "C" { |
73 |
|
#endif |
74 |
|
|
75 |
|
|
76 |
|
/********************************/ |
77 |
|
/* Our conventions for things */ |
78 |
|
/* we choose to do differently */ |
79 |
|
/* on WIN16 vs. WIN32. */ |
80 |
|
/********************************/ |
81 |
|
|
82 |
|
#ifdef WIN16 |
83 |
|
|
84 |
|
#define MULDIV(x,y,z) MulDiv32(x,y,z) |
85 |
|
#define IsBadReadPtr(lp,cb) FBadReadPtr(lp,cb) |
86 |
|
|
87 |
|
#define cInstMax 50 |
88 |
|
LPVOID FAR PASCAL PvGetInstanceGlobals(void); |
89 |
|
LONG FAR PASCAL ScSetInstanceGlobals(LPVOID pv); |
90 |
|
LONG FAR PASCAL ScSetVerifyInstanceGlobals(LPVOID pv, DWORD dwPid); |
91 |
|
LPVOID FAR PASCAL PvGetVerifyInstanceGlobals(DWORD dwPid); |
92 |
|
LPVOID FAR PASCAL PvSlowGetInstanceGlobals(DWORD dwPid); |
93 |
|
BOOL __export FAR PASCAL FCleanupInstanceGlobals(WORD, DWORD); |
94 |
|
|
95 |
|
#elif defined(_MAC) /* !WIN16 */ |
96 |
|
|
97 |
|
#define MULDIV(x,y,z) MulDiv(x,y,z) |
98 |
|
|
99 |
|
LPVOID FAR PASCAL PvGetInstanceGlobals(WORD wDataSet); |
100 |
|
LONG FAR PASCAL ScSetInstanceGlobals(LPVOID pv, WORD wDataSet); |
101 |
|
LONG FAR PASCAL ScSetVerifyInstanceGlobals(LPVOID pv, DWORD dwPid, |
102 |
|
WORD wDataSet); |
103 |
|
LPVOID FAR PASCAL PvGetVerifyInstanceGlobals(DWORD dwPid, DWORD wDataSet); |
104 |
|
LPVOID FAR PASCAL PvSlowGetInstanceGlobals(DWORD dwPid, DWORD wDataSet); |
105 |
|
BOOL FAR PASCAL FCleanupInstanceGlobals(WORD, DWORD); |
106 |
|
|
107 |
|
#else /* !WIN16 */ |
108 |
|
|
109 |
|
#define MULDIV(x,y,z) MulDiv(x,y,z) |
110 |
|
|
111 |
|
extern LPVOID pinstX; |
112 |
|
#define PvGetInstanceGlobals() pinstX |
113 |
|
#define ScSetInstanceGlobals(_pv) (pinstX = _pv, 0) |
114 |
|
#define PvGetVerifyInstanceGlobals(_pid) pinstX |
115 |
|
#define ScSetVerifyInstanceGlobals(_pv,_pid) (pinstX = _pv, 0) |
116 |
|
#define PvSlowGetInstanceGlobals(_pid) pinstX |
117 |
|
|
118 |
|
#endif /* WIN16 */ |
119 |
|
|
120 |
|
#if defined(_WIN32) && !defined(_MAC) |
121 |
|
#define szMAPIDLLSuffix "32" |
122 |
|
#elif defined(WIN16) || defined(DOS) |
123 |
|
#define szMAPIDLLSuffix "" |
124 |
|
#elif defined(_MAC) |
125 |
|
#define szMAPIDLLSuffix "M" |
126 |
|
#else |
127 |
|
#error "Don't know the suffix for DLLs on this platform" |
128 |
|
#endif |
129 |
|
|
130 |
|
/********************************/ |
131 |
|
/* Things missing from one */ |
132 |
|
/* system-provided environment */ |
133 |
|
/* or the other. */ |
134 |
|
/********************************/ |
135 |
|
|
136 |
|
#if !defined(_WIN32) |
137 |
|
#define ZeroMemory(pb,cb) memset((pb),0,(cb)) |
138 |
|
#define FillMemory(pb,cb,b) memset((pb),(b),(cb)) |
139 |
|
#define CopyMemory(pbDst,pbSrc,cb) do \ |
140 |
|
{ \ |
141 |
|
size_t _cb = (size_t)(cb); \ |
142 |
|
if (_cb) \ |
143 |
|
memcpy(pbDst,pbSrc,_cb);\ |
144 |
|
} while (FALSE) |
145 |
|
#define MoveMemory(pbDst,pbSrc,cb) memmove((pbDst),(pbSrc),(cb)) |
146 |
|
|
147 |
|
#define UNALIGNED |
148 |
|
|
149 |
|
#endif |
150 |
|
|
151 |
|
#if defined(WIN16) || defined(_MAC) |
152 |
|
|
153 |
|
#ifndef _MAC |
154 |
|
#include <error.h> /* for GetLastError() */ |
155 |
|
#endif |
156 |
|
|
157 |
|
typedef int INT; |
158 |
|
typedef unsigned long ULONG; |
159 |
|
typedef short SHORT; |
160 |
|
typedef unsigned short USHORT; |
161 |
|
typedef double LONGLONG; |
162 |
|
typedef double DWORDLONG; |
163 |
|
typedef unsigned char UCHAR; |
164 |
|
typedef unsigned char FAR* PUCHAR; |
165 |
|
typedef int BOOL; |
166 |
|
|
167 |
|
|
168 |
|
#ifndef _MAC |
169 |
|
typedef char BOOLEAN; |
170 |
|
|
171 |
|
#ifndef _FILETIME_ |
172 |
|
#define _FILETIME_ |
173 |
|
typedef struct tagFILETIME |
174 |
|
{ |
175 |
|
DWORD dwLowDateTime; |
176 |
|
DWORD dwHighDateTime; |
177 |
|
} FILETIME; |
178 |
|
#endif /* _FILETIME */ |
179 |
|
|
180 |
|
typedef struct _SYSTEMTIME { |
181 |
|
WORD wYear; |
182 |
|
WORD wMonth; |
183 |
|
WORD wDayOfWeek; |
184 |
|
WORD wDay; |
185 |
|
WORD wHour; |
186 |
|
WORD wMinute; |
187 |
|
WORD wSecond; |
188 |
|
WORD wMilliseconds; |
189 |
|
} SYSTEMTIME, *PSYSTEMTIME, FAR *LPSYSTEMTIME; |
190 |
|
|
191 |
|
typedef struct _TIME_ZONE_INFORMATION { |
192 |
|
LONG Bias; |
193 |
|
CHAR StandardName[ 32 ]; /* was WCHAR */ |
194 |
|
SYSTEMTIME StandardDate; |
195 |
|
LONG StandardBias; |
196 |
|
CHAR DaylightName[ 32 ]; /* was WCHAR */ |
197 |
|
SYSTEMTIME DaylightDate; |
198 |
|
LONG DaylightBias; |
199 |
|
} TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION, FAR *LPTIME_ZONE_INFORMATION; |
200 |
|
|
201 |
|
|
202 |
|
#if defined(DOS) || defined(WIN16) |
203 |
|
/* Simulate effect of afx header */ |
204 |
|
#define __T(x) x |
205 |
|
#define _T(x) __T(x) |
206 |
|
#define TEXT _T |
207 |
|
#endif |
208 |
|
|
209 |
|
#define APIENTRY WINAPI |
210 |
|
|
211 |
|
#define SetForegroundWindow SetActiveWindow |
212 |
|
|
213 |
|
#define wsprintfA wsprintf |
214 |
|
#define GetWindowsDirectoryA GetWindowsDirectory |
215 |
|
#define GetSystemDirectoryA GetSystemDirectory |
216 |
|
#define GetPrivateProfileStringA GetPrivateProfileString |
217 |
|
#define GetPrivateProfileIntA GetPrivateProfileInt |
218 |
|
#define GetProfileStringA GetProfileString |
219 |
|
#define GetModuleFileNameA GetModuleFileName |
220 |
|
#define CharUpperBuffA CharUpperBuff |
221 |
|
#define LoadLibraryA LoadLibrary |
222 |
|
#define lstrcatA lstrcat |
223 |
|
#define RegisterWindowMessageA RegisterWindowMessage |
224 |
|
#define MAKEINTRESOURCEA MAKEINTRESOURCE |
225 |
|
|
226 |
|
#define WNDCLASSA WNDCLASS |
227 |
|
|
228 |
|
#endif /* !_MAC */ |
229 |
|
|
230 |
|
/* Synchronization */ |
231 |
|
#define InterlockedIncrement(plong) (++(*(plong))) |
232 |
|
#define InterlockedDecrement(plong) (--(*(plong))) |
233 |
|
|
234 |
|
#ifndef CreateMutex |
235 |
|
#define CreateMutexA CreateMutex |
236 |
|
#define CreateMutexW CreateMutex |
237 |
|
#define CreateMutex(pv, bool, sz) (INVALID_HANDLE_VALUE) |
238 |
|
#endif |
239 |
|
|
240 |
|
#define WaitForSingleObject(hObj, dw) ((void)0) |
241 |
|
#define ReleaseMutex(hObj) ((BOOL)1) |
242 |
|
#define CloseMutexHandle(hObj) TRUE |
243 |
|
|
244 |
|
#define CRITICAL_SECTION ULONG |
245 |
|
#define InitializeCriticalSection(_pcs) ((void)0) |
246 |
|
#define DeleteCriticalSection(_pcs) ((void)0) |
247 |
|
#define EnterCriticalSection(_pcs) ((void)0) |
248 |
|
#define LeaveCriticalSection(_pcs) ((void)0) |
249 |
|
|
250 |
|
#define MAX_PATH 260 |
251 |
|
|
252 |
|
#ifndef _MAC |
253 |
|
/* |
254 |
|
* File Access Modes |
255 |
|
* |
256 |
|
* The possible combination of file access modes as passed into |
257 |
|
* the CreateFile() api map to OpenFile() as follows: |
258 |
|
* |
259 |
|
* GENERIC_READ OPEN_ACCESS_READONLY |
260 |
|
* GENERIC_WRITE OPEN_ACCESS_WRITEONLY |
261 |
|
* GENERIC_READ | GENERIC_WRITE OPEN_ACCESS_READWRITE |
262 |
|
* |
263 |
|
* 0 OPEN_SHARE_DENYREADWRITE |
264 |
|
* FILE_SHARE_READ OPEN_SHARE_DENYWRITE |
265 |
|
* FILE_SHARE_WRITE OPEN_SHARE_DENYREAD |
266 |
|
* FILE_SHARE_READ | FILE_SHARE_WRITE OPEN_SHARE_DENYNONE |
267 |
|
* |
268 |
|
* Due to the mappings we cannot pass them through directly, |
269 |
|
* so we will have to use a conversion within APIs that test |
270 |
|
* these bits. It would be best to use the Win32 #defines |
271 |
|
* for these flags and convert as needed in the APIs. |
272 |
|
*/ |
273 |
|
#define GENERIC_READ (0x80000000) /* from WINNT.H */ |
274 |
|
#define GENERIC_WRITE (0x40000000) /* from WINNT.H */ |
275 |
|
#define FILE_SHARE_READ (0x00000001) /* from WINNT.H */ |
276 |
|
#define FILE_SHARE_WRITE (0x00000002) /* from WINNT.H */ |
277 |
|
#endif /* _MAC */ |
278 |
|
|
279 |
|
#define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000 |
280 |
|
|
281 |
|
#define CREATE_NEW 1 |
282 |
|
#define CREATE_ALWAYS 2 |
283 |
|
#define OPEN_EXISTING 3 |
284 |
|
#define OPEN_ALWAYS 4 |
285 |
|
#define TRUNCATE_EXISTING 5 |
286 |
|
|
287 |
|
#ifndef _MAC |
288 |
|
#define INVALID_HANDLE_VALUE ((HANDLE)(-1)) |
289 |
|
#define DELETE 0x00010000L |
290 |
|
|
291 |
|
#define FILE_BEGIN 0 |
292 |
|
#define FILE_CURRENT 1 |
293 |
|
#define FILE_END 2 |
294 |
|
#endif |
295 |
|
|
296 |
|
#define FILE_ATTRIBUTE_READONLY 0x00000001 |
297 |
|
#define FILE_ATTRIBUTE_HIDDEN 0x00000002 |
298 |
|
#define FILE_ATTRIBUTE_SYSTEM 0x00000004 |
299 |
|
#define FILE_ATTRIBUTE_DIRECTORY 0x00000010 |
300 |
|
#define FILE_ATTRIBUTE_ARCHIVE 0x00000020 |
301 |
|
#define FILE_ATTRIBUTE_NORMAL 0x00000080 |
302 |
|
#define FILE_ATTRIBUTE_TEMPORARY 0x00000100 |
303 |
|
|
304 |
|
#define FILE_FLAG_WRITE_THROUGH 0x80000000 |
305 |
|
#define FILE_FLAG_RANDOM_ACCESS 0x10000000 |
306 |
|
|
307 |
|
#ifndef _MAC |
308 |
|
typedef struct _WIN32_FIND_DATA { |
309 |
|
DWORD dwFileAttributes; |
310 |
|
FILETIME ftCreationTime; |
311 |
|
FILETIME ftLastAccessTime; |
312 |
|
FILETIME ftLastWriteTime; |
313 |
|
DWORD nFileSizeHigh; |
314 |
|
DWORD nFileSizeLow; |
325 |
|
#define TIME_ZONE_ID_DAYLIGHT 2 |
326 |
|
|
327 |
|
|
328 |
|
|
329 |
|
DWORD WINAPI GetLastError(void); |
330 |
|
DWORD WINAPI GetFileAttributes(LPCSTR lpFileName); |
331 |
|
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh); |
332 |
|
BOOL WINAPI GetFileTime(HANDLE hFile, FILETIME FAR *lpftCreation, |
333 |
|
FILETIME FAR *lpftLastAccess, FILETIME FAR *lpftLastWrite); |
334 |
|
BOOL WINAPI SetFileTime(HANDLE hFile, const FILETIME FAR *lpftCreation, |
335 |
|
const FILETIME FAR *lpftLastAccess, |
336 |
|
const FILETIME FAR *lpftLastWrite); |
337 |
|
#ifndef _MAC |
338 |
|
/* IsTask can crash - here's a safer one. */ |
339 |
|
BOOL WINAPI FIsTask(HTASK hTask); |
340 |
|
|
341 |
|
HANDLE WINAPI CreateFile(LPCSTR lpFileName, DWORD dwDesiredAccess, |
342 |
|
DWORD dwShareMode, LPVOID lpSecurityAttributes, |
343 |
|
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, |
344 |
|
HANDLE hTemplateFile); |
345 |
|
BOOL WINAPI ReadFile(HANDLE hFile, LPVOID lpBuffer, |
346 |
|
DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, |
347 |
|
LPVOID lpOverlapped); |
348 |
|
BOOL WINAPI WriteFile(HANDLE hFile, LPCVOID lpBuffer, |
349 |
|
DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, |
350 |
|
LPVOID lpOverlapped); |
351 |
|
#endif |
352 |
|
DWORD WINAPI SetFilePointer(HANDLE hFile, LONG lDistanceToMove, |
353 |
|
LONG FAR *lpDistanceToMoveHigh, DWORD dwMoveMethod); |
354 |
|
BOOL WINAPI SetEndOfFile(HANDLE hFile); |
355 |
|
BOOL WINAPI CloseHandle(HANDLE hObject); |
356 |
|
DWORD WINAPI GetTempPath(DWORD nBufferLength, LPSTR lpBuffer); |
357 |
|
UINT WINAPI GetTempFileName32 (LPCSTR lpPathName, LPCSTR lpPrefixString, |
358 |
|
UINT uUnique, LPSTR lpTempFileName); |
359 |
|
BOOL WINAPI DeleteFile(LPCSTR lpFileName); |
360 |
|
#ifndef _MAC |
361 |
|
BOOL WINAPI CreateDirectory(LPCSTR lpPathName, LPVOID lpSecurityAttributes); |
362 |
|
#endif |
363 |
|
BOOL WINAPI RemoveDirectory(LPCSTR lpPathName); |
364 |
|
BOOL WINAPI CopyFile(LPCSTR szSrc, LPCSTR szDst, BOOL fFailIfExists); |
365 |
|
BOOL WINAPI MoveFile(LPCSTR lpExistingFileName, LPCSTR lpNewFileName); |
366 |
|
HANDLE WINAPI FindFirstFile(LPCSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData); |
367 |
|
BOOL WINAPI FindNextFile(HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData); |
368 |
|
BOOL WINAPI FindClose(HANDLE hFindFile); |
369 |
|
DWORD WINAPI GetFullPathName(LPCSTR lpFileName, DWORD nBufferLength, |
370 |
|
LPSTR lpBuffer, LPSTR *lpFilePart); |
371 |
|
void WINAPI Sleep(DWORD dwMilliseconds); |
372 |
|
LONG WINAPI CompareFileTime(const FILETIME FAR *, const FILETIME FAR *); |
373 |
|
BOOL WINAPI LocalFileTimeToFileTime(const FILETIME FAR *, FILETIME FAR *); |
374 |
|
BOOL WINAPI FileTimeToLocalFileTime(const FILETIME FAR *, FILETIME FAR *); |
375 |
|
BOOL WINAPI FileTimeToSystemTime(const FILETIME FAR *, SYSTEMTIME FAR *); |
376 |
|
BOOL WINAPI SystemTimeToFileTime(const SYSTEMTIME FAR *, FILETIME FAR *); |
377 |
|
void WINAPI GetSystemTime(SYSTEMTIME FAR *); |
378 |
|
void WINAPI GetLocalTime(SYSTEMTIME FAR *); |
379 |
|
BOOL WINAPI FileTimeToDosDateTime(const FILETIME FAR * lpFileTime, |
380 |
|
WORD FAR *lpFatDate, WORD FAR *lpFatTime); |
381 |
|
BOOL WINAPI DosDateTimeToFileTime(WORD wFatDate, WORD wFatTime, |
382 |
|
FILETIME FAR * lpFileTime); |
383 |
|
DWORD WINAPI GetTimeZoneInformation( |
384 |
|
LPTIME_ZONE_INFORMATION lpTimeZoneInformation); |
385 |
|
BOOL WINAPI SetTimeZoneInformation( |
386 |
|
const TIME_ZONE_INFORMATION FAR *lpTimeZoneInformation); |
387 |
|
|
388 |
|
DWORD WINAPI GetCurrentProcessId(void); |
389 |
|
long WINAPI MulDiv32(long, long, long); |
390 |
|
#ifndef _MAC |
391 |
|
BOOL WINAPI FBadReadPtr(const void FAR* lp, UINT cb); |
392 |
|
#endif |
393 |
|
|
394 |
|
#else /* !WIN16 */ |
395 |
|
|
396 |
|
/* Remaps GetTempFileName32() to the real 32bit version */ |
397 |
|
|
398 |
|
#define GetTempFileName32(_szPath,_szPfx,_n,_lpbuf) GetTempFileName(_szPath,_szPfx,_n,_lpbuf) |
399 |
|
|
400 |
|
#define CloseMutexHandle CloseHandle |
401 |
|
|
402 |
|
#endif /* !WIN16 */ |
403 |
|
|
404 |
|
|
405 |
|
#ifdef _MAC |
406 |
|
#define CRITICAL_SECTION ULONG |
407 |
|
#define InitializeCriticalSection(_pcs) ((void)0) |
408 |
|
#define DeleteCriticalSection(_pcs) ((void)0) |
409 |
|
#define EnterCriticalSection(_pcs) ((void)0) |
410 |
|
#define LeaveCriticalSection(_pcs) ((void)0) |
411 |
|
#endif |
412 |
|
|
413 |
|
/********************************/ |
414 |
|
/* Our private conventions */ |
415 |
|
/* (common to WIN16/WIN32) */ |
416 |
|
/********************************/ |
417 |
|
|
418 |
|
#define Cbtszsize(_a) ((lstrlen(_a)+1)*sizeof(TCHAR)) |
419 |
|
#define CbtszsizeA(_a) ((lstrlenA(_a) + 1)) |
420 |
|
#define CbtszsizeW(_a) ((lstrlenW(_a) + 1) * sizeof(WCHAR)) |
421 |
|
#define HexCchOf(_s) (sizeof(_s)*2+1) |
422 |
|
#define HexSizeOf(_s) (HexCchOf(_s)*sizeof(TCHAR)) |
423 |
|
|
424 |
|
BOOL WINAPI IsBadBoundedStringPtr(const void FAR* lpsz, UINT cchMax); |
425 |
|
|
426 |
|
#ifdef __cplusplus |
427 |
|
} |
428 |
|
#endif |
429 |
|
|
430 |
|
#endif /* __MAPIWIN_H__ */ |
431 |
|
|
432 |
|
|
433 |
|
|
|
|
|