vbacom互操作问题
VBA COM interop troubles
我有一些来自MSDN的示例代码,我试图适应使用,但VBA编译器拒绝尖括号< >
的内容。我在一个模块中有以下代码:
Imports System
Imports System.Runtime.InteropServices
<DllImport("../../insert_dll_name_here.dll", CallingConvention:=CallingConvention.Cdecl)> _
Public Function Test(file() As String) As Integer
End Function
我试图使用此代码从c++ dll中调用一个简单的函数,该函数期望字符串数组,但我得到编译错误"预期行号或标签或语句或语句结束",并且没有找到提供的帮助菜单是任何用途。我已经尝试了方括号[ ]
,以防这是VBA版本的问题,无济于事。有人能指出我在使用COM互操作服务时的错误吗?
代码为VB.NET。这不是VBA。
在VBA中,你会写
Declare Function Test Lib "../../insert_dll_name_here.dll" (file() As String) As Long
然而,VBA不直接支持cdecl
约定,但您可以使其与类型库一起工作。你也可能会遇到file() As String
数组的问题-确保在c++端正确处理它。
作为旁注,这与COM无关。这是从外部库调用函数。
相关文章:
- 如何读取 C++ SAFEARRAY**,该 SAFEARRAY** 是 COM 互操作的结果,其中 C# 返回值为
- 编译为 wasm 的 C++ 和 Rust 程序可以以某种方式互操作吗?
- 有什么语言可以与C++互操作吗
- 使 Flutter C/C++ 互操作示例正常工作
- C++互操作(隐式 PInvoke)的限制
- COM 互操作结构定义与内存布局不匹配
- _Complex 和 std::complex 之间的 C/C++ 互操作
- C# COM 服务器互操作 - System.InvalidCastException.
- 从C++与 C 灵活阵列成员互操作的正确方法是什么?
- 如何通过 COM 互操作访问复杂对象的属性?
- 如何区分"QObject"的亲子关系关注点,例如与其他所有者进行互操作?
- DirectWrite GDI 互操作:使用"IDWriteFontFace"绘制文本的简单方法
- opencl openGL互操作内核参数用于读取 写入
- Rust 互操作与 C++ std::string
- 将互操作 HwndSource 包装在 c++/cli 中,以用于本机 c++/MFC 应用程序
- 跨 C# 和 COM 互操作使用对象C++
- vbacom互操作问题
- c++ /CLR (c++互操作)基本问题:)
- 此互操作 C#/托管/非托管C++参数传递有什么问题?
- OpenCL/OpenGL纹理互操作/窗口的问题