I am trying to call a dll file created in vb6 from F#. I have written the following dll.
Public Function AddTwoNumbers(ByVal a As Integer, ByVal b As Integer)
AddTwoNumbers = a + b
End Function
Now I want to call it in my F# program, I wrote this code
open System.Runtime.InteropServices
module InteropWithNative =
[<DllImport(@"C:\add", CallingConvention = CallingConvention.Cdecl)>]
void AddTwoNumbers(int, int)
InteropWithNative.AddTwoNumbers(3,4)
let result = AddTwoNumbers_ 2.0 3.0
It gives me errors and doesn't recognize the function.
答案 0 :(得分:2)
带有EntryPoint的工作互操作示例
open System.Runtime.InteropServices // for DllImport
module KernelInterop =
[<DllImport("kernel32.dll", EntryPoint="Beep")>]
extern void Beep( int frequency, int duration )
KernelInterop.Beep // val Beep : int * int -> unit
KernelInterop.Beep(440, 1000)