gpt4 book ai didi

c# - 如何在 C# 上为包装的 C++ 方法编写签名,该方法具有指向函数及其参数的指针?

转载 作者:行者123 更新时间:2023-11-30 03:05:50 24 4
gpt4 key购买 nike

我正在为一个 dll 编写一个包装器。该 dll 有一个方法,其签名类似于以下内容:

unsigned long aMethod(void *anyParameter, 
void (*anotherMethod)(const char *, void *))

我在谷歌上搜索了一个教程,让我深入了解如何在 C# 上编写签名,以便框架可以执行编码过程。

怎么写呢?您知道有关此主题的任何教程、书籍或文档吗?

最佳答案

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void AnotherMethodDelegate(string s, IntPtr anyParameter);

[DllImport("dllname",
CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Ansi)]
uint aMethod(IntPtr anyParameter, AnotherMethodDelegate anotherMethod);

关于c# - 如何在 C# 上为包装的 C++ 方法编写签名,该方法具有指向函数及其参数的指针?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7410382/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com