Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registry module #1909

Merged
merged 7 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
194 changes: 97 additions & 97 deletions .fake/build.fsx/intellisense.fsx

Large diffs are not rendered by default.

68 changes: 42 additions & 26 deletions Fake.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 12.00

Microsoft Visual Studio Solution File, Format Version 12.00
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, just autogenerated msvc stuff, didn't realize that was added in

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh actually, it looks like we need that. That's in the current master of fake.sln as well

# Visual Studio 15
VisualStudioVersion = 15.0.27130.2026
MinimumVisualStudioVersion = 15.0.26124.0
Expand Down Expand Up @@ -125,9 +126,11 @@ EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Tools.Pickles", "src/app/Fake.Tools.Pickles/Fake.Tools.Pickles.fsproj", "{2EC1798B-3AD5-42FE-9406-F358B995ACC3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution Files", "{03CB61B6-EBB8-4C4A-B6A3-0D84D1F78A92}"
ProjectSection(SolutionItems) = preProject
build.fsx = build.fsx
EndProjectSection
ProjectSection(SolutionItems) = preProject
build.fsx = build.fsx
EndProjectSection
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Windows.Registry", "src/app/Fake.Windows.Registry/Fake.Windows.Registry.fsproj", "{71259EF7-41FD-4068-BD85-E4C7F67EAC25}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -307,6 +310,18 @@ Global
{93F1A71E-54E2-4C65-BB1E-1D499890317F}.Release|x64.Build.0 = Release|Any CPU
{93F1A71E-54E2-4C65-BB1E-1D499890317F}.Release|x86.ActiveCfg = Release|Any CPU
{93F1A71E-54E2-4C65-BB1E-1D499890317F}.Release|x86.Build.0 = Release|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Debug|x64.ActiveCfg = Debug|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Debug|x64.Build.0 = Debug|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Debug|x86.ActiveCfg = Debug|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Debug|x86.Build.0 = Debug|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Release|Any CPU.Build.0 = Release|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Release|x64.ActiveCfg = Release|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Release|x64.Build.0 = Release|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Release|x86.ActiveCfg = Release|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Release|x86.Build.0 = Release|Any CPU
{C1B87E1F-8D0D-4A78-9A24-9D5D38B7E9A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C1B87E1F-8D0D-4A78-9A24-9D5D38B7E9A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C1B87E1F-8D0D-4A78-9A24-9D5D38B7E9A8}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -703,18 +718,6 @@ Global
{77E0066D-A04D-445B-B036-9008A40F8A44}.Release|x64.Build.0 = Release|Any CPU
{77E0066D-A04D-445B-B036-9008A40F8A44}.Release|x86.ActiveCfg = Release|Any CPU
{77E0066D-A04D-445B-B036-9008A40F8A44}.Release|x86.Build.0 = Release|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Debug|x64.ActiveCfg = Debug|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Debug|x64.Build.0 = Debug|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Debug|x86.ActiveCfg = Debug|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Debug|x86.Build.0 = Debug|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Release|Any CPU.Build.0 = Release|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Release|x64.ActiveCfg = Release|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Release|x64.Build.0 = Release|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Release|x86.ActiveCfg = Release|Any CPU
{819E2756-7BEE-4FCD-BA08-7BF323405CBE}.Release|x86.Build.0 = Release|Any CPU
{B636A082-4DB4-439D-8A37-E5214BDC00A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B636A082-4DB4-439D-8A37-E5214BDC00A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B636A082-4DB4-439D-8A37-E5214BDC00A3}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -753,16 +756,16 @@ Global
{3BC4A91C-3381-4BF9-BF11-8E06706CF878}.Release|x86.Build.0 = Release|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|x64.ActiveCfg = Debug|x64
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|x64.Build.0 = Debug|x64
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|x86.ActiveCfg = Debug|x86
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|x86.Build.0 = Debug|x86
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|x64.ActiveCfg = Debug|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|x64.Build.0 = Debug|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|x86.ActiveCfg = Debug|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|x86.Build.0 = Debug|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|Any CPU.Build.0 = Release|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|x64.ActiveCfg = Release|x64
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|x64.Build.0 = Release|x64
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|x86.ActiveCfg = Release|x86
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|x86.Build.0 = Release|x86
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|x64.ActiveCfg = Release|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|x64.Build.0 = Release|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|x86.ActiveCfg = Release|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|x86.Build.0 = Release|Any CPU
{4E702236-A2B1-4920-B56D-4746CC0726D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E702236-A2B1-4920-B56D-4746CC0726D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E702236-A2B1-4920-B56D-4746CC0726D3}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -811,6 +814,18 @@ Global
{2EC1798B-3AD5-42FE-9406-F358B995ACC3}.Release|x64.Build.0 = Release|Any CPU
{2EC1798B-3AD5-42FE-9406-F358B995ACC3}.Release|x86.ActiveCfg = Release|Any CPU
{2EC1798B-3AD5-42FE-9406-F358B995ACC3}.Release|x86.Build.0 = Release|Any CPU
{71259EF7-41FD-4068-BD85-E4C7F67EAC25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71259EF7-41FD-4068-BD85-E4C7F67EAC25}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71259EF7-41FD-4068-BD85-E4C7F67EAC25}.Debug|x64.ActiveCfg = Debug|Any CPU
{71259EF7-41FD-4068-BD85-E4C7F67EAC25}.Debug|x64.Build.0 = Debug|Any CPU
{71259EF7-41FD-4068-BD85-E4C7F67EAC25}.Debug|x86.ActiveCfg = Debug|Any CPU
{71259EF7-41FD-4068-BD85-E4C7F67EAC25}.Debug|x86.Build.0 = Debug|Any CPU
{71259EF7-41FD-4068-BD85-E4C7F67EAC25}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71259EF7-41FD-4068-BD85-E4C7F67EAC25}.Release|Any CPU.Build.0 = Release|Any CPU
{71259EF7-41FD-4068-BD85-E4C7F67EAC25}.Release|x64.ActiveCfg = Release|Any CPU
{71259EF7-41FD-4068-BD85-E4C7F67EAC25}.Release|x64.Build.0 = Release|Any CPU
{71259EF7-41FD-4068-BD85-E4C7F67EAC25}.Release|x86.ActiveCfg = Release|Any CPU
{71259EF7-41FD-4068-BD85-E4C7F67EAC25}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -828,9 +843,9 @@ Global
{C3C12DCE-7AC4-4E97-A7FC-49189D218885} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{BB293F2E-C3BD-4F1C-8345-8AEF01998D2C} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{B2C0063A-FC66-4883-BB69-B1DBE6BF9CA2} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{D8CFE7F9-8E14-4B22-9729-7FF431AFE36B} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{64195C50-E138-4218-A7CE-13CD4565B87E} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{93F1A71E-54E2-4C65-BB1E-1D499890317F} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{819E2756-7BEE-4FCD-BA08-7BF323405CBE} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{C1B87E1F-8D0D-4A78-9A24-9D5D38B7E9A8} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{75C9DD21-B4EA-4117-BF4F-AFE777A80B5B} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{21E2FE31-4E7C-489E-8215-9303108A2F39} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
Expand Down Expand Up @@ -866,14 +881,15 @@ Global
{E09B72E4-D890-46A8-8D14-7367C2E23E9D} = {539D7B9A-18A1-4D79-86AB-C8B48090CA84}
{8561A35A-C2A4-43C7-A938-CB35A7747121} = {E09B72E4-D890-46A8-8D14-7367C2E23E9D}
{77E0066D-A04D-445B-B036-9008A40F8A44} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{819E2756-7BEE-4FCD-BA08-7BF323405CBE} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{B636A082-4DB4-439D-8A37-E5214BDC00A3} = {901F162F-8925-4390-89C5-9EE2C343F744}
{DE7579F2-C20F-4C35-BC04-C10362912243} = {901F162F-8925-4390-89C5-9EE2C343F744}
{3BC4A91C-3381-4BF9-BF11-8E06706CF878} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D} = {901F162F-8925-4390-89C5-9EE2C343F744}
{4E702236-A2B1-4920-B56D-4746CC0726D3} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{DA58D728-C36A-4DC7-8D92-F2BA13667EA5} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{D8CFE7F9-8E14-4B22-9729-7FF431AFE36B} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{2EC1798B-3AD5-42FE-9406-F358B995ACC3} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{71259EF7-41FD-4068-BD85-E4C7F67EAC25} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {058A0C5E-2216-4306-8AFB-0AE28320C26A}
Expand Down
1 change: 1 addition & 0 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ let dotnetAssemblyInfos =
"Fake.Testing.Common", "Common testing data types"
"Fake.Tracing.NAntXml", "NAntXml"
"Fake.Windows.Chocolatey", "Running and packaging with Chocolatey"
"Fake.Windows.Registry", "CRUD functionality for Windows registry"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add it to help/templates/template.cshtml, ie to add it to the menu in the Windows modules submenu?

Just reference the API-Reference there (no need to add a new markdown documentation)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need help with this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry you already added it.

"Fake.Testing.SonarQube", "Analyzing your project with SonarQube"
"Fake.Testing.ReportGenerator", "Convert XML coverage output to various formats"
"Fake.DotNet.Testing.OpenCover", "Code coverage with OpenCover"
Expand Down
17 changes: 17 additions & 0 deletions src/app/Fake.Windows.Registry/AssemblyInfo.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Auto-Generated by FAKE; do not edit
namespace System
open System.Reflection

[<assembly: AssemblyTitleAttribute("FAKE - F# CRUD functionality for Windows registry")>]
[<assembly: AssemblyProductAttribute("FAKE - F# Make")>]
[<assembly: AssemblyVersionAttribute("5.0.0")>]
[<assembly: AssemblyInformationalVersionAttribute("5.0.0-beta025")>]
[<assembly: AssemblyFileVersionAttribute("5.0.0")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "FAKE - F# CRUD functionality for Windows registry"
let [<Literal>] AssemblyProduct = "FAKE - F# Make"
let [<Literal>] AssemblyVersion = "5.0.0"
let [<Literal>] AssemblyInformationalVersion = "5.0.0-beta025"
let [<Literal>] AssemblyFileVersion = "5.0.0"
18 changes: 18 additions & 0 deletions src/app/Fake.Windows.Registry/Fake.Windows.Registry.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetFrameworks>net46;netstandard1.6;netstandard2.0</TargetFrameworks>
<AssemblyName>Fake.Windows.Registry</AssemblyName>
<OutputType>Library</OutputType>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>$(DefineConstants);FX_NO_REMOTING;USE_ASYNC_LOCAL</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="Registry.fs" />
</ItemGroup>
<Import Project="..\..\..\.paket\Paket.Restore.targets" />
</Project>
112 changes: 112 additions & 0 deletions src/app/Fake.Windows.Registry/Registry.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/// Contains functions which allow to read and write information from/to the registry.
module Fake.Windows.Registry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a sample to the reference documentation.
Similar to
https://github.com/fsharp/FAKE/blob/83f79896d303c081039fd887885ca5c74c95526b/src/app/Fake.Core.ReleaseNotes/ReleaseNotes.fs#L1-L39

We would also like to add RequireQualifiedAccess here.


open Microsoft.Win32

/// Registry base keys.
type RegistryBaseKey =
| HKEYLocalMachine
| HKEYClassesRoot
| HKEYUsers
| HKEYCurrentUser
| HKEYCurrentConfig
| HKEYPerformanceData

/// Maps the RegistryBaseKey to a RegistryKey
/// [omit]
let getKey name =
match name with
| HKEYLocalMachine -> Registry.LocalMachine
| HKEYClassesRoot -> Registry.ClassesRoot
| HKEYUsers -> Registry.Users
| HKEYCurrentUser -> Registry.CurrentUser
| HKEYCurrentConfig -> Registry.CurrentConfig
| HKEYPerformanceData -> Registry.PerformanceData

/// Maps the RegistryBaseKey to a RegistryKey for a 64bit System
/// [omit]
let get64BitKey name =
match name with
| HKEYLocalMachine -> RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)
| HKEYClassesRoot -> RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry64)
| HKEYUsers -> RegistryKey.OpenBaseKey(RegistryHive.Users, RegistryView.Registry64)
| HKEYCurrentUser -> RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64)
| HKEYCurrentConfig -> RegistryKey.OpenBaseKey(RegistryHive.CurrentConfig, RegistryView.Registry64)
| HKEYPerformanceData -> RegistryKey.OpenBaseKey(RegistryHive.PerformanceData, RegistryView.Registry64)

/// Maps the RegistryBaseKey to a RegistryKey for a 32bit System
/// [omit]
let get32BitKey name =
match name with
| HKEYLocalMachine -> RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)
| HKEYClassesRoot -> RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry32)
| HKEYUsers -> RegistryKey.OpenBaseKey(RegistryHive.Users, RegistryView.Registry32)
| HKEYCurrentUser -> RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32)
| HKEYCurrentConfig -> RegistryKey.OpenBaseKey(RegistryHive.CurrentConfig, RegistryView.Registry32)
| HKEYPerformanceData -> RegistryKey.OpenBaseKey(RegistryHive.PerformanceData, RegistryView.Registry32)

/// Gets a 64-bit registry key
let getRegistryKey64 baseKey subKey (writePermission : bool) =
(get64BitKey baseKey).OpenSubKey(subKey, writePermission)

/// Gets a registry key and falls back to 32 bit if the 64bit key is not there
let getRegistryKey baseKey subKey (writePermission : bool) =
let x64BitKey = (getKey baseKey).OpenSubKey(subKey, writePermission)
if (isNull >> not) x64BitKey then x64BitKey else
(get32BitKey baseKey).OpenSubKey(subKey, writePermission) // fall back to 32 bit

/// Gets a registry value as string
let getRegistryValue baseKey subKey name =
use key = getRegistryKey baseKey subKey false
if isNull key then
failwithf "Registry subkey %s could not be found for key %A" subKey baseKey
let value = key.GetValue name
if isNull value then
failwithf "Registry value is null for key %s" (key.ToString())
value.ToString()

/// Gets a registry value as string
let getRegistryValue64 baseKey subKey name =
use key = getRegistryKey64 baseKey subKey false
if isNull key then
failwithf "Registry subkey %s could not be found for key %A" subKey baseKey
let value = key.GetValue name
if isNull value then
failwithf "Registry value is null for key %s" (key.ToString())
value.ToString()

/// Sets a registry value
let setRegistryValue<'T> baseKey subKey name (value : 'T) =
use key = getRegistryKey baseKey subKey true
key.SetValue(name, value)

/// Deletes the registry value from its key
let deleteRegistryValue baseKey subKey name =
use key = getRegistryKey baseKey subKey true
key.DeleteValue name

/// Returns all the value names of a registry key
let getRegistryValueNames baseKey subKey =
use key = getRegistryKey baseKey subKey false
key.GetValueNames()

/// Returns whether or not a registry value name exists for a key
let valueExistsForKey = fun baseKey subKey name ->
getRegistryValueNames baseKey subKey
|> Seq.exists (fun n -> n = name)

/// Create a registry subKey
let createRegistrySubKey baseKey subKey =
use key = getKey baseKey
key.CreateSubKey subKey |> ignore

/// Deletes a registry subKey
let deleteRegistrySubKey baseKey subKey =
use key = getKey baseKey
key.DeleteSubKey subKey

/// Returns all the subKey names of a registry key
let getRegistrySubKeyNames baseKey subKey =
use key = getRegistryKey baseKey subKey false
key.GetSubKeyNames()

5 changes: 5 additions & 0 deletions src/app/Fake.Windows.Registry/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
group netcore

FSharp.Core
NETStandard.Library
Microsoft.Win32.Registry
5 changes: 4 additions & 1 deletion src/legacy/FakeLib/FakeLib.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@
<Compile Include="..\..\app\Fake.Sql.DacPac\Sql.DacPac.fs">
<Link>Fake.Sql.DacPac\Sql.DacPac.fs</Link>
</Compile>
<Compile Include="..\..\app\Fake.Windows.Registry\Registry.fs">
<Link>Fake.Windows.Registry\Registry.fs</Link>
</Compile>
<Compile Include="UserInputHelper.fs" />
<Compile Include="CSharpHelper.fs" />
<Compile Include="EnvironmentHelper.fs" />
Expand Down Expand Up @@ -2702,4 +2705,4 @@
</When>
</Choose>
<Import Project="..\..\..\packages\NETStandard.Library\build\$(__paket__NETStandard_Library_targets).targets" Condition="Exists('..\..\..\packages\NETStandard.Library\build\$(__paket__NETStandard_Library_targets).targets')" Label="Paket" />
</Project>
</Project>
Loading