c++ - 使用 mapi.h 函数
问题描述
我想从 mapi.h 头文件中调用 MAPISendMail 函数。在我的 c++ 动态库项目中,我有 MathLibrary.h 文件,其中包含以下代码:
#ifdef MATHLIBRARY_EXPORTS
#define MATHLIBRARY_API __declspec(dllexport)
#else
#define MATHLIBRARY_API __declspec(dllimport)
#endif
#include <windows.h>
#include <mapi.h>
extern "C" MATHLIBRARY_API ULONG MAPISendMail(LHANDLE lhSession,
ULONG_PTR ulUIParam,
lpMapiMessage lpMessage,
FLAGS flFlags,
ULONG ulReserved);
MathLibrary.cpp 文件:
#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier
#include <utility>
#include <limits.h>
#include "MathLibrary.h"
#include <fstream>
#include <string>
// DLL internal state variables:
static unsigned long long previous_; // Previous value, if any
static unsigned long long current_; // Current sequence value
static unsigned index_; // Current seq. position
ULONG MAPISendMail(LHANDLE lhSession,
ULONG_PTR ulUIParam,
lpMapiMessage lpMessage,
FLAGS flFlags,
ULONG ulReserved)
{
//HERE I WOULD LIKE TO READ MAIL ATTACHMENT FILE PATH
MessageBoxW(NULL, L"MAPISendMail!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
std::ofstream outfile;
outfile.open("test.txt", std::ios_base::app); // append instead of overwrite
outfile << "Mapisenddocuments";
return 0;
}
我收到此错误:
错误 C2373 'MAPISendMail':重新定义;不同的类型修饰符 DllTestHeader
我的目标是创建将使用 Mapi 函数来获取和处理电子邮件附件文件路径的 dll。
解决方案
推荐阅读
- css - 如何将 css 盒子阴影转换为 IOS 阴影
- sql - SQL 语句 - Is NULL & IS Not Null;
- php - 如何在 WooCommerce 中检查订单是否已支付
- .net - 如何调查不同地区的 Azure Function 冷启动较慢?
- php - 多维阵列到单个
- ios - 由于 Xcode 错误,无法在 WebStorm 中调试 React Native
- sockets - 期望使用套接字向后台作业发送密码
- javascript - TinyMCE 上传图片:JSON 输入意外结束
- python - 从时间戳列表中获取小时和分钟
- ubuntu - 在操作系统中分配 CPU 到进程意味着什么?