c# - 将结构从 C++ 传递到 CLI

标签 c# c++ .net

以下结构从 C++ 传递到 CLI(供 C# 项目使用)。 它正在传递一个 int 和一个结构数组:

public value struct CallbackInfo
{
public:
    int callbackType;
    [MarshalAsAttribute(System::Runtime::InteropServices::UnmanagedType::ByValArray, ArraySubType = System::Runtime::InteropServices::UnmanagedType::LPStruct, SizeConst=1)] array<SystemInfo>^ SystemInfo;     
};

我如何修改它以便它只传递 struct SystemInfo 的一个拷贝?而不是大小为 1 的数组??

最佳答案

声明如下:

public value struct CallbackInfo
{
public:
    int callbackType;
    SystemInfo systemInfo;     
};

关于c# - 将结构从 C++ 传递到 CLI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22538322/

相关文章:

C# 使用附加参数附加事件处理

c# - 带套接字连接的后台运行服务器

c++ - gSOAP 到 WCF。应用程序/soap+xml;字符集=utf-8

c# - 以编程方式为 .net 站点设置 "Convert to Application"选项

c# - ListView 子项字体不起作用

C#/WPF : Disable Text-Wrap of RichTextBox

c# - 在 RX 中有没有办法将源流绑定(bind)到目标流,以便可以在不影响客户端订阅的情况下更改源?

c++ - 为什么有或没有 const 修饰符会使效率相差 4 倍?

c++ - 'L' 在这里有什么意义?

.net - 日期时间格式与 SQL Server 中的格式不匹配