我尝试了两个星期来创建一个 DLL,我可以向其传递字符串并取回字符串。但仍然没有成功。
我在 Dev-C++(TDM-GCC 4.9.2) 和 Visual Studio 社区 2015 上尝试了这个。我对此进行了很多搜索,并尝试了我找到的几乎所有示例代码,但没有成功。
我必须将此 DLL 与MetaTrader 终端 4一起使用。
这是我使用的一个示例代码。此代码编译成功,但是当我从 MT4string
发送到此代码时,我收到访问冲突错误。
#ifndef MYLIB_HPP
#define MYLIB_HPP
#include <string>
#ifdef MYLIB_EXPORTS
#define MYLIB_API __declspec(dllimport)
#else
#define MYLIB_API __declspec(dllexport)
#endif
bool MYLIB_API test(const std::string& str);
#endif
bool MYLIB_API MyTest(const std::string& str)
{
return (str == "Hi There");
}