【发布时间】:2019-01-20 20:39:57
【问题描述】:
我有一个导出 DLL 的简单程序,这个 DLL 从另一个 DLL 导出函数:
// SDK_DLL.cpp :
#include "functions.h"
#include "functions_advanced.h"
#include "stdafx.h"
#include <stdio.h>
using namespace std;
extern "C"
{
__declspec(dllexport) void DisplayHelloFromDLL()
{
printf("Hello from DLL...");
}
__declspec(dllexport) function_config FuncInit = appd_config_init();
__declspec(dllexport) function_config * FuncInit2()
{
function_config* cfg = function_config_init();
return cfg;
}
}
function_config_init() 返回一个指针,我似乎找不到做出正确导出声明的方法。
我正在通过这种方式将一个简单的函数加载到 Delphi:
procedure DisplayHelloFromDLL; external 'C:\Users\Administrator\Documents\Visual Studio 2017\Projects\SDK_DLL\Debug\SDK_DLL.dll';
是否需要更改加载此指针返回函数的方式?
非常感谢您的帮助。
【问题讨论】:
-
程序错误,因为它得到了错误的调用约定。很难知道你的意思。你想知道函数的 Delphi 语法。您肯定会在文档中找到它。你不能像这样学习一门语言,在 SO 上问这些问题。你也不能指望通过互操作项目来学习。