MAPINIT.C
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:2k
源码类别:

Windows编程

开发平台:

Visual C++

  1. #include <windows.h>
  2. #include "mapi.h"
  3. #include "mapinit.h"
  4. extern HANDLE hLibrary;
  5. int FAR PASCAL InitMAPI()
  6. {
  7.   if ((hLibrary = LoadLibrary(MAPIDLL)) < (HANDLE)32)
  8.     return(ERR_LOAD_LIB);
  9.   if ((lpfnMAPILogon = (PFNMAPILOGON)GetProcAddress(hLibrary,SZ_MAPILOGON)) == NULL)
  10.     return(ERR_LOAD_FUNC);
  11.   if ((lpfnMAPILogoff= (PFNMAPILOGOFF)GetProcAddress(hLibrary,SZ_MAPILOGOFF)) == NULL)
  12.     return(ERR_LOAD_FUNC);
  13.   if ((lpfnMAPISendMail= (PFNMAPISENDMAIL)GetProcAddress(hLibrary,SZ_MAPISENDMAIL)) == NULL)
  14.     return(ERR_LOAD_FUNC);
  15.   if ((lpfnMAPISendDocuments= (PFNMAPISENDDOCUMENTS)GetProcAddress(hLibrary,SZ_MAPISENDDOC)) == NULL)
  16.     return(ERR_LOAD_FUNC);
  17.   if ((lpfnMAPIFindNext= (PFNMAPIFINDNEXT)GetProcAddress(hLibrary,SZ_MAPIFINDNEXT)) == NULL)
  18.     return(ERR_LOAD_FUNC);
  19.   if ((lpfnMAPIReadMail= (PFNMAPIREADMAIL)GetProcAddress(hLibrary,SZ_MAPIREADMAIL)) == NULL)
  20.     return(ERR_LOAD_FUNC);
  21.   if ((lpfnMAPISaveMail= (PFNMAPISAVEMAIL)GetProcAddress(hLibrary,SZ_MAPISAVEMAIL)) == NULL)
  22.     return(ERR_LOAD_FUNC);
  23.   if ((lpfnMAPIDeleteMail= (PFNMAPIDELETEMAIL)GetProcAddress(hLibrary,SZ_MAPIDELMAIL)) == NULL)
  24.     return(ERR_LOAD_FUNC);
  25.   if ((lpfnMAPIFreeBuffer= (PFNMAPIFREEBUFFER)GetProcAddress(hLibrary,SZ_MAPIFREEBUFFER)) == NULL)
  26.     return(ERR_LOAD_FUNC);
  27.   if ((lpfnMAPIAddress= (PFNMAPIADDRESS)GetProcAddress(hLibrary,SZ_MAPIADDRESS)) == NULL)
  28.     return(ERR_LOAD_FUNC);
  29.   if ((lpfnMAPIDetails= (PFNMAPIDETAILS)GetProcAddress(hLibrary,SZ_MAPIDETAILS)) == NULL)
  30.     return(ERR_LOAD_FUNC);
  31.   if ((lpfnMAPIResolveName= (PFNMAPIRESOLVENAME)GetProcAddress(hLibrary,SZ_MAPIRESOLVENAME)) == NULL)
  32.     return(ERR_LOAD_FUNC);
  33.   return(0);
  34. }
  35. int FAR PASCAL DeInitMAPI()
  36. {
  37.   lpfnMAPILogon = NULL;
  38.   lpfnMAPILogoff= NULL;
  39.   lpfnMAPISendMail= NULL;
  40.   lpfnMAPISendDocuments= NULL;
  41.   lpfnMAPIFindNext= NULL;
  42.   lpfnMAPIReadMail= NULL;
  43.   lpfnMAPISaveMail= NULL;
  44.   lpfnMAPIDeleteMail= NULL;
  45.   lpfnMAPIFreeBuffer = NULL;
  46.   lpfnMAPIAddress= NULL;
  47.   lpfnMAPIDetails = NULL;
  48.   lpfnMAPIResolveName;
  49.   FreeLibrary(hLibrary);
  50.   return(0);
  51. }