Skip to content

Instantly share code, notes, and snippets.

@Thorium
Created March 4, 2012 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Thorium/1972331 to your computer and use it in GitHub Desktop.
Save Thorium/1972331 to your computer and use it in GitHub Desktop.
Getting a key from Windows registry
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