DllImport - C类型到.NET类型

时间:2011-04-01 09:19:25

标签: c# f# dllimport

我有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

1 个答案:

答案 0 :(得分:2)

尝试类似:

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

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