Added methods and interfaces for File History -- tests still failing

pull/250/head
dahall 2021-09-30 12:14:05 -06:00
parent c70f8bc29b
commit 2251e5d7b1
5 changed files with 1375 additions and 0 deletions

1280
PInvoke/FhSvcCtl/FhSvcCtl.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<ProjectExtensions>
<SupportedDlls>fhsvcctl.dll</SupportedDlls>
</ProjectExtensions>
<PropertyGroup>
<Description>PInvoke API (methods, structures and constants) imported from Windows FhSvcCtl.dll.</Description>
<AssemblyTitle>$(AssemblyName)</AssemblyTitle>
<TargetFrameworks>net20;net35;net40;net45;net5.0-windows;netstandard2.0;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<AssemblyName>Vanara.PInvoke.FhSvcCtl</AssemblyName>
<PackageId>$(AssemblyName)</PackageId>
<PackageTags>pinvoke;vanara;net-extensions;interop;FhSvcCtl;file history</PackageTags>
<PackageReleaseNotes/>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Core\Vanara.Core.csproj" />
<ProjectReference Include="..\Shared\Vanara.PInvoke.Shared.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>UnitTest.PInvoke.FhSvcCtl</AssemblyName>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\PInvoke\FhSvcCtl\Vanara.PInvoke.FhSvcCtl.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,52 @@
using NUnit.Framework;
using NUnit.Framework.Internal;
using System;
using System.Runtime.InteropServices;
using static Vanara.PInvoke.FhSvcCtl;
namespace Vanara.PInvoke.Tests
{
[TestFixture]
public class FhSvcCtlTests
{
[OneTimeSetUp]
public void _Setup()
{
}
[DllImport(Lib.Kernel32, CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)]
static extern HINSTANCE LoadLibraryEx(string lpFileName, [Optional] IntPtr hFile, uint dwFlags);
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool FreeLibrary(HINSTANCE hModule);
[OneTimeTearDown]
public void _TearDown()
{
}
[Test]
public void TestIntf()
{
var mgr = new IFhConfigMgr();
mgr.LoadConfiguration();
}
[Test]
public void TestFn()
{
HINSTANCE hi;
Assert.That(hi = LoadLibraryEx(@"C:\Windows\System32\fhsvccfg.dll", default, 0x1000), ResultIs.ValidHandle);
FreeLibrary(hi);
Assert.That(FhServiceOpenPipe(true, out var hPipe), ResultIs.Successful);
Assert.That(FhServiceReloadConfiguration(hPipe), ResultIs.Successful);
Assert.That(FhServiceStartBackup(hPipe, true), ResultIs.Successful);
Assert.That(FhServiceBlockBackup(hPipe), ResultIs.Successful);
Assert.That(FhServiceUnblockBackup(hPipe), ResultIs.Successful);
Assert.That(FhServiceStopBackup(hPipe, false), ResultIs.Successful);
Assert.That(() => hPipe.Dispose(), Throws.Nothing);
}
}
}

View File

@ -323,6 +323,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.PInvoke.CimFs", "PIn
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CimFs", "UnitTests\PInvoke\CimFs\CimFs.csproj", "{5DBC32A2-1FF0-41F6-9D6B-CE701F599BE0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vanara.PInvoke.FhSvcCtl", "PInvoke\FhSvcCtl\Vanara.PInvoke.FhSvcCtl.csproj", "{B419C1F3-AB66-40B9-9693-817CD061F7EF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FhSvcCtl", "UnitTests\PInvoke\FhSvcCtl\FhSvcCtl.csproj", "{089EA815-567E-4430-BEB4-4E18FD0B1473}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -1058,6 +1062,16 @@ Global
{5DBC32A2-1FF0-41F6-9D6B-CE701F599BE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DBC32A2-1FF0-41F6-9D6B-CE701F599BE0}.DebugNoTests|Any CPU.ActiveCfg = Debug|Any CPU
{5DBC32A2-1FF0-41F6-9D6B-CE701F599BE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B419C1F3-AB66-40B9-9693-817CD061F7EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B419C1F3-AB66-40B9-9693-817CD061F7EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B419C1F3-AB66-40B9-9693-817CD061F7EF}.DebugNoTests|Any CPU.ActiveCfg = Debug|Any CPU
{B419C1F3-AB66-40B9-9693-817CD061F7EF}.DebugNoTests|Any CPU.Build.0 = Debug|Any CPU
{B419C1F3-AB66-40B9-9693-817CD061F7EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B419C1F3-AB66-40B9-9693-817CD061F7EF}.Release|Any CPU.Build.0 = Release|Any CPU
{089EA815-567E-4430-BEB4-4E18FD0B1473}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{089EA815-567E-4430-BEB4-4E18FD0B1473}.Debug|Any CPU.Build.0 = Debug|Any CPU
{089EA815-567E-4430-BEB4-4E18FD0B1473}.DebugNoTests|Any CPU.ActiveCfg = Debug|Any CPU
{089EA815-567E-4430-BEB4-4E18FD0B1473}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -1201,6 +1215,8 @@ Global
{AD86DDF6-F5BA-4A4D-85BE-8D2415FCA1CC} = {385CAD2D-0A5E-4F80-927B-D5499D126B90}
{5C26B1D5-B826-40D0-8D8C-024250FBB306} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90}
{5DBC32A2-1FF0-41F6-9D6B-CE701F599BE0} = {385CAD2D-0A5E-4F80-927B-D5499D126B90}
{B419C1F3-AB66-40B9-9693-817CD061F7EF} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90}
{089EA815-567E-4430-BEB4-4E18FD0B1473} = {385CAD2D-0A5E-4F80-927B-D5499D126B90}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {543FAC75-2AF1-4EF1-9609-B242B63FEED4}