开发者

DllImport - C types to .NET types

开发者 https://www.devze.com 2023-02-21 01:05 出处:网络
I\'ve got dll function DLLExport int PatchSomething(char*, char*, DWORD, unsigned char*, unsigned short int);

I've got dll function

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

but can't fully transfer parameters to .NET

F# :

module 开发者_如何学PythonRNInvoke

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);

or C#

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

errors on unsigned char* and unsigned short int


Try something like:

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

You might need to throw CharSet = Auto into the attribute too. My only concerns are on the unsigned char pointer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号