Created
March 4, 2012 10:41
-
-
Save Thorium/1972331 to your computer and use it in GitHub Desktop.
Getting a key from Windows registry
This file contains 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
let REGISTRYSOFTWARE = "Software"; | |
let REGISTRYMYPATH = "MySoftware"; | |
let internal GetRegistryValue key = | |
use path1 = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(REGISTRYSOFTWARE) | |
match path1 with | |
| null -> failwith("Access failed to registry: hklm\\"+REGISTRYSOFTWARE) | |
| keyhklmsw -> | |
use path2 = keyhklmsw.OpenSubKey(REGISTRYMYPATH) | |
match path2 with | |
| null -> failwith("Access failed to registry: " + REGISTRYMYPATH) | |
| keyhklmswmypath -> | |
match keyhklmswmypath.GetValue(key, null) with | |
| null -> failwith("Path not found: " + key) | |
| gotkey -> gotkey | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment