gpt4 book ai didi

c# - DllImport - C 类型到 .NET 类型

转载 作者:太空宇宙 更新时间:2023-11-03 11:38:23 26 4
gpt4 key购买 nike

我有dll函数

DLLExport int PatchSomething(char*, char*, DWORD, unsigned char*, unsigned short int);

但无法将参数完全传递给.NET

F#:

模块 RNInvoke

open System
open System.Runtime.InteropServices
open Microsoft.FSharp.NativeInterop
open Microsoft.FSharp.Math

module Native =
[<System.Runtime.InteropServices.DllImport("DesuDLL.dll",EntryPoint="add")>]
extern int PatchSomething(char*, char*, DWORD, unsigned char*, unsigned short int);

或 C#

[DllImport("DesuDLL.dll")]
private static extern int PatchSomething(char*, char*, DWORD, unsigned char*, unsigned short int);

unsigned char*unsigned short int 错误

最佳答案

尝试这样的事情:

[DllImport("DesuDLL.dll")]
private static extern int PatchSomething(string a,string b,uint c,string d,ushort e);

您可能还需要将 CharSet = Auto 放入属性中。我唯一关心的是 unsigned char 指针。

关于c# - DllImport - C 类型到 .NET 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5511431/

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