DllImport - C types to .NET types
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.
精彩评论