Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

431 lines
13 KiB

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