2015-09-17 74 views
1

最初在这里发布(https://stackoverflow.com/questions/32617735/declared-dll-but-errors-external-function-not-found),但被告知不要使用类和名称空间。重新发布一个简单的例子,我仍然无法工作。声明的Hello World DLL文件。在运行时没有找到外部函数

DLL用C++(Visual Studio中)制成:

// myFirstDLL.h 
#define DECLDIR __declspec(dllexport) 

DECLDIR int GIMMEFIVE(); 



// myFirstDLL.cpp 
#include "stdafx.h" 
#include "myFirstDLL.h" 
#include <stdexcept> 

//using namespace std; 

int GIMMEFIVE() 
{ 
    return 5; 
} 

LotusScript代理:

Option Public 
Option Declare 

Declare Public Function GIMMEFIVE Lib "P:\Internet\dplows\visualstudio\myFirstDLL\myFirstDLL\Debug\myFirstDLL.dll"() As Integer 

Sub Initialize 
    MsgBox GIMMEFIVE() 

End Sub 
+0

莲花脚本预计什么调用约定? – Niall

+0

@Niall,它非常类似于VB。只是FYI,我已经成功地从DLL中调用函数(通过user32.dll在任务栏中刷新当前窗口)。一定是我的错。 – dplows

+0

[This may help](http://www-01.ibm.com/support/knowledgecenter/#!/SSVRGU_9.0.1/com.ibm.designer.domino.main.doc/LSAZ_WORKING_WITH_EXTERNAL_C_LANGUAGE_FUNCTIONS.html)。您可能还想使用Dependency Walker查看导出函数的名称。我不知道louts脚本,但VBA可能会对函数名称感到烦恼(https://msdn.microsoft.com/en-us/library/aa235591(v=vs.60).aspx) – Niall

回答

3

是必需的功能将被包裹在extern "C"块;

extern "C" 
{ 
    extern __declspec(dllexport) int GIMMEFIVE(); 
} 
0

声明它为双方extern "C"__declspec(dllexport)。如果您不是从DLL中调用函数,则不需要转发声明它。你可以这样做全部内联:

extern "C" __declspec(dllexport) int GIMMEFIVE() 
{ 
    return 5; 
}