28 people like it.
Like the snippet!
Getting a key from Windows registry
F# code to fetch a registry key
1: let REGISTRYSOFTWARE = "Software"; 2: let REGISTRYMYPATH = "MySoftware"; 3: 4: let internal GetRegistryValue key = 5: use path1 = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(REGISTRYSOFTWARE) 6: match path1 with 7: | null -> failwith("Access failed to registry: hklm\\"+REGISTRYSOFTWARE) 8: | keyhklmsw -> 9: use path2 = keyhklmsw.OpenSubKey(REGISTRYMYPATH) 10: match path2 with 11: | null -> failwith("Access failed to registry: " + REGISTRYMYPATH) 12: | keyhklmswmypath -> 13: match keyhklmswmypath.GetValue(key, null) with 14: | null -> failwith("Path not found: " + key) 15: | gotkey -> gotkey 16: 17:
val REGISTRYSOFTWARE : string
Full name: Test.REGISTRYSOFTWARE
type: string
implements: System.IComparable
implements: System.ICloneable
implements: System.IConvertible
implements: System.IComparable<string>
implements: seq<char>
implements: System.Collections.IEnumerable
implements: System.IEquatable<string>
Full name: Test.REGISTRYSOFTWARE
type: string
implements: System.IComparable
implements: System.ICloneable
implements: System.IConvertible
implements: System.IComparable<string>
implements: seq<char>
implements: System.Collections.IEnumerable
implements: System.IEquatable<string>
val REGISTRYMYPATH : string
Full name: Test.REGISTRYMYPATH
type: string
implements: System.IComparable
implements: System.ICloneable
implements: System.IConvertible
implements: System.IComparable<string>
implements: seq<char>
implements: System.Collections.IEnumerable
implements: System.IEquatable<string>
Full name: Test.REGISTRYMYPATH
type: string
implements: System.IComparable
implements: System.ICloneable
implements: System.IConvertible
implements: System.IComparable<string>
implements: seq<char>
implements: System.Collections.IEnumerable
implements: System.IEquatable<string>
val internal GetRegistryValue : string -> obj
Full name: Test.GetRegistryValue
Full name: Test.GetRegistryValue
val key : string
type: string
implements: System.IComparable
implements: System.ICloneable
implements: System.IConvertible
implements: System.IComparable<string>
implements: seq<char>
implements: System.Collections.IEnumerable
implements: System.IEquatable<string>
type: string
implements: System.IComparable
implements: System.ICloneable
implements: System.IConvertible
implements: System.IComparable<string>
implements: seq<char>
implements: System.Collections.IEnumerable
implements: System.IEquatable<string>
val path1 : Microsoft.Win32.RegistryKey
type: Microsoft.Win32.RegistryKey
implements: System.IDisposable
inherits: System.MarshalByRefObject
type: Microsoft.Win32.RegistryKey
implements: System.IDisposable
inherits: System.MarshalByRefObject
namespace Microsoft
namespace Microsoft.Win32
type Registry =
class
static val CurrentUser : Microsoft.Win32.RegistryKey
static val LocalMachine : Microsoft.Win32.RegistryKey
static val ClassesRoot : Microsoft.Win32.RegistryKey
static val Users : Microsoft.Win32.RegistryKey
static val PerformanceData : Microsoft.Win32.RegistryKey
static val CurrentConfig : Microsoft.Win32.RegistryKey
static val DynData : Microsoft.Win32.RegistryKey
static member GetValue : string * string * obj -> obj
static member SetValue : string * string * obj -> unit
static member SetValue : string * string * obj * Microsoft.Win32.RegistryValueKind -> unit
end
Full name: Microsoft.Win32.Registry
class
static val CurrentUser : Microsoft.Win32.RegistryKey
static val LocalMachine : Microsoft.Win32.RegistryKey
static val ClassesRoot : Microsoft.Win32.RegistryKey
static val Users : Microsoft.Win32.RegistryKey
static val PerformanceData : Microsoft.Win32.RegistryKey
static val CurrentConfig : Microsoft.Win32.RegistryKey
static val DynData : Microsoft.Win32.RegistryKey
static member GetValue : string * string * obj -> obj
static member SetValue : string * string * obj -> unit
static member SetValue : string * string * obj * Microsoft.Win32.RegistryValueKind -> unit
end
Full name: Microsoft.Win32.Registry
field Microsoft.Win32.Registry.LocalMachine
Multiple overloads
Microsoft.Win32.RegistryKey.OpenSubKey(name: string) : Microsoft.Win32.RegistryKey
Microsoft.Win32.RegistryKey.OpenSubKey(name: string, permissionCheck: Microsoft.Win32.RegistryKeyPermissionCheck) : Microsoft.Win32.RegistryKey
Microsoft.Win32.RegistryKey.OpenSubKey(name: string, writable: bool) : Microsoft.Win32.RegistryKey
Microsoft.Win32.RegistryKey.OpenSubKey(name: string, permissionCheck: Microsoft.Win32.RegistryKeyPermissionCheck, rights: System.Security.AccessControl.RegistryRights) : Microsoft.Win32.RegistryKey
Microsoft.Win32.RegistryKey.OpenSubKey(name: string) : Microsoft.Win32.RegistryKey
Microsoft.Win32.RegistryKey.OpenSubKey(name: string, permissionCheck: Microsoft.Win32.RegistryKeyPermissionCheck) : Microsoft.Win32.RegistryKey
Microsoft.Win32.RegistryKey.OpenSubKey(name: string, writable: bool) : Microsoft.Win32.RegistryKey
Microsoft.Win32.RegistryKey.OpenSubKey(name: string, permissionCheck: Microsoft.Win32.RegistryKeyPermissionCheck, rights: System.Security.AccessControl.RegistryRights) : Microsoft.Win32.RegistryKey
val failwith : string -> 'T
Full name: Microsoft.FSharp.Core.Operators.failwith
Full name: Microsoft.FSharp.Core.Operators.failwith
val keyhklmsw : Microsoft.Win32.RegistryKey
type: Microsoft.Win32.RegistryKey
implements: System.IDisposable
inherits: System.MarshalByRefObject
type: Microsoft.Win32.RegistryKey
implements: System.IDisposable
inherits: System.MarshalByRefObject
val path2 : Microsoft.Win32.RegistryKey
type: Microsoft.Win32.RegistryKey
implements: System.IDisposable
inherits: System.MarshalByRefObject
type: Microsoft.Win32.RegistryKey
implements: System.IDisposable
inherits: System.MarshalByRefObject
val keyhklmswmypath : Microsoft.Win32.RegistryKey
type: Microsoft.Win32.RegistryKey
implements: System.IDisposable
inherits: System.MarshalByRefObject
type: Microsoft.Win32.RegistryKey
implements: System.IDisposable
inherits: System.MarshalByRefObject
Multiple overloads
Microsoft.Win32.RegistryKey.GetValue(name: string) : obj
Microsoft.Win32.RegistryKey.GetValue(name: string, defaultValue: obj) : obj
Microsoft.Win32.RegistryKey.GetValue(name: string, defaultValue: obj, options: Microsoft.Win32.RegistryValueOptions) : obj
Microsoft.Win32.RegistryKey.GetValue(name: string) : obj
Microsoft.Win32.RegistryKey.GetValue(name: string, defaultValue: obj) : obj
Microsoft.Win32.RegistryKey.GetValue(name: string, defaultValue: obj, options: Microsoft.Win32.RegistryValueOptions) : obj
val gotkey : obj
More information
| Link: | http://fssnip.net/1m |
| Posted: | 2 years ago |
| Author: | Tuomas Hietanen (website) |
| Tags: | Registry |