Created
August 8, 2013 13:20
-
-
Save mavnn/6184518 to your computer and use it in GitHub Desktop.
Add a dll directory from which to DllImport native code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open System | |
| open System.Runtime.InteropServices | |
| open System.ComponentModel | |
| [<DllImport("kernel32")>] | |
| extern int AddDllDirectory(string NewDirectory) | |
| [<EntryPoint>] | |
| let main argv = | |
| let result = AddDllDirectory("c:\\") | |
| if result = 0 then | |
| printfn "%A" <| Win32Exception(Marshal.GetLastWin32Error()) | |
| // Prints: "System.ComponentModel.Win32Exception (0x80004005): The parameter is incorrect" | |
| System.Console.ReadLine() |> ignore | |
| 0 // return an integer exit code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code is being run on a Windows 8 machine, btw. I'm aware you need to apply a patch to use this api call on earlier versions of Windows.