Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/164.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在code::blocks中创建dll文件并在powerpoint 2007中使用_C++_Dll_Powerpoint_Codeblocks_Declare - Fatal编程技术网

C++ 在code::blocks中创建dll文件并在powerpoint 2007中使用

C++ 在code::blocks中创建dll文件并在powerpoint 2007中使用,c++,dll,powerpoint,codeblocks,declare,C++,Dll,Powerpoint,Codeblocks,Declare,我已经厌倦了在代码块中创建dll文件,然后在powerpoint演示文稿中使用它。在我下面提到的dll文件中,函数的参数包含(LPCSTR) 在我的powerpoint文件中,我有 Declare Function DLL_EXPORT _ Lib "myfile.dll" _ Alias "SomeFunction" (???) 当我运行文件时,我得到 因为我不知道如何在powerpoint中定义函数的参数。我的意思是这部分代码: Alias "SomeFunction" (???)

我已经厌倦了在代码块中创建dll文件,然后在powerpoint演示文稿中使用它。在我下面提到的dll文件中,函数的参数包含(LPCSTR

在我的powerpoint文件中,我有

Declare Function DLL_EXPORT _
Lib "myfile.dll" _
Alias "SomeFunction" (???)  
当我运行文件时,我得到
因为我不知道如何在powerpoint中定义函数的参数。我的意思是这部分代码:

 Alias "SomeFunction" (???)

<>你的C++代码使用错误的调用约定。应该是:

__declspec(dllexport) void __stdcall SomeFunction(const char* sometext)
如果愿意,可以使用诸如
DLL\u EXPORT
apitery
LPCSTR
等宏。但是,至少在您了解宏的全部含义之前,可能更容易明确,正如我上面所示

函数的正确VBA声明为:

Declare Sub SomeFunction Lib "myfile.dll" (ByVal sometext As String)
然而,这是不够的,因为您的功能将受到名称装饰和损坏。您可以使用dumpbin或Dependency Walker查看导出函数的实际名称。然后需要修改VBA声明,如下所示:

Declare Sub SomeFunction Lib "myfile.dll" Alias "<DecoratedNameHere>" (ByVal sometext As String)
声明Sub-SomeFunction Lib“myfile.dll”Alias”“(ByVal sometext作为字符串)

声明函数SomeFunction Lib“myfile.dll”别名“SomeFunction”(ByVal sometext作为字符串)
。还要确保您的本地
SomeFunction
使用Pascal调用约定。另请参见。我已经使用ByVal sometext作为字符串,但它不起作用。但我不确定调用函数的方法。例如,我使用了:DLL_EXPORT(“Hello World”)
DLL_EXPORT
不是函数名。它是一个C++宏,能够为DLL实现和DLL的客户端使用相同的头文件。它可能扩展到
外部“C”
。调用约定应指定为:
DLL\u EXPORT void\u stdcall SomeFunction(const LPCSTR sometext)
。DLL文件的其余代码是:extern“C”DLL\u EXPORT BOOL apient DllMain(HINSTANCE hinstDLL,DWORD fdreason,LPVOID lpvReserved){此处的一些代码…返回TRUE;}感谢@IInspectable的帮助。我从下面的电影中得到了一些想法[
Declare Sub SomeFunction Lib "myfile.dll" Alias "<DecoratedNameHere>" (ByVal sometext As String)