小编mle*_*ega的帖子

Marshal数组的结构和IntPtr

我非常接近我的问题的解决方案,但我需要一些关于最后润色的指导,以使一切正常.在过去的一周里,我学到了很多东西

作为参考,我上周就同一个话题提出了类似的问题,但由于我身边的巨大疏忽,我提出了错误的问题.

我正在尝试使用非托管c ++ dll,它是与连接设备进行通信的API.我已经成功创建了包装器,以及大多数其他函数调用,但最后一个让我发疯.

对于一些背景信息(可能不需要回答这个问题 - 并记住我的基本思维过程当时存在缺陷)在这里:用指针调用未托管代码(更新)

在我原来的问题中,我问的是为包含struct(2)数组的struct(1)创建一个IntPtr ....实际上,struct(1)根本不包含一个数组,它包含一个指针数组.

以下是我试图实现的API的文档作为参考:

extern “C” long WINAPI PassThruIoctl
(
    unsigned long ChannelID,
    unsigned long IoctlID,
    void *pInput,
    void *pOutput
)


// *pInput Points to the structure SCONFIG_LIST, which is defined as follows:
// *pOutput is not used in this function and is a null pointer

typedef struct
{
    unsigned long NumOfParams; /* number of SCONFIG elements */
    SCONFIG *ConfigPtr; /* array of SCONFIG */
} SCONFIG_LIST

// Where:
// NumOfParms is …
Run Code Online (Sandbox Code Playgroud)

c# struct

2
推荐指数
1
解决办法
7706
查看次数

标签 统计

c# ×1

struct ×1