I am trying to call EnumWindows from F# and got following exception:
System.Runtime.InteropServices.MarshalDirectiveException: Cannot marshal 'parameter #1': Generic types cannot be marshaled.
Code I used:
module Win32 =
open System
open System.Runtime.InteropServices
type EnumWindowsProc = delegate of (IntPtr * IntPtr) -> bool
[<DllImport("user32.dll")>]
extern bool EnumWindows(EnumWindowsProc callback, IntPtr lParam)
let EnumTopWindows() =
let callback = new EnumWindowsProc(fun (hwnd, lparam) -> true)
EnumWindows(callback, IntPtr.Zero)
module Test =
printfn "%A" (Win32.EnumTopWindows())