From 26a82802a655acc287e535a97ede523b44cb192b Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 12 Sep 2023 16:50:01 -0600 Subject: [PATCH] Added error messages to FhSvcCtl --- PInvoke/FhSvcCtl/FhSvcCtl.cs | 83 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/PInvoke/FhSvcCtl/FhSvcCtl.cs b/PInvoke/FhSvcCtl/FhSvcCtl.cs index f2c64a12..f8c17186 100644 --- a/PInvoke/FhSvcCtl/FhSvcCtl.cs +++ b/PInvoke/FhSvcCtl/FhSvcCtl.cs @@ -1,6 +1,3 @@ -using System; -using System.Runtime.InteropServices; - namespace Vanara.PInvoke; /// Items from the FhSvcCtl.dll for File History. @@ -8,6 +5,8 @@ public static partial class FhSvcCtl { private const string Lib_FhSvcCtl = "fhsvcctl.dll"; + static FhSvcCtl() => StaticFieldValueHash.AddFields(); + /// Specifies whether File History backups are enabled. /// /// @@ -331,6 +330,84 @@ public static partial class FhSvcCtl FH_TARGET_DRIVE_TYPE, } + /// The definitions of the error codes returned by File History APIs and components. + [PInvokeData("fherrors.h")] + public enum FHERR : int + { + // Error codes for the Configuration Manager. (0x0300 - 0x03ff) + + /// The Config File is corrupted and hence invalid + FHCFG_E_CORRUPT_CONFIG_FILE = unchecked((int)(0x80040000 + 0x0300)), + + /// The Config File not found + FHCFG_E_CONFIG_FILE_NOT_FOUND = unchecked((int)(0x80040000 + 0x0301)), + + /// The Config File already exists + FHCFG_E_CONFIG_ALREADY_EXISTS = unchecked((int)(0x80040000 + 0x0302)), + + /// A valid configuration has not been loaded + FHCFG_E_NO_VALID_CONFIGURATION_LOADED = unchecked((int)(0x80040000 + 0x0303)), + + /// Target is not connected + FHCFG_E_TARGET_NOT_CONNECTED = unchecked((int)(0x80040000 + 0x0304)), + + /// Configuration has been loaded previously + FHCFG_E_CONFIGURATION_PREVIOUSLY_LOADED = unchecked((int)(0x80040000 + 0x0305)), + + /// Default target verification failed + FHCFG_E_TARGET_VERIFICATION_FAILED = unchecked((int)(0x80040000 + 0x0306)), + + /// Target is not configured + FHCFG_E_TARGET_NOT_CONFIGURED = unchecked((int)(0x80040000 + 0x0307)), + + /// Target doesn't have enough free space + FHCFG_E_TARGET_NOT_ENOUGH_FREE_SPACE = unchecked((int)(0x80040000 + 0x0308)), + + /// Target cannot be used for File History + FHCFG_E_TARGET_CANNOT_BE_USED = unchecked((int)(0x80040000 + 0x0309)), + + /// Rehydration can't be performed in the current configuration state + FHCFG_E_INVALID_REHYDRATION_STATE = unchecked((int)(0x80040000 + 0x30A)), + + /// Changing target recommendation is not allowed + FHCFG_E_RECOMMENDATION_CHANGE_NOT_ALLOWED = unchecked((int)(0x80040000 + 0x0310)), + + /// The target was rehydrated on another PC. + FHCFG_E_TARGET_REHYDRATED_ELSEWHERE = unchecked((int)(0x80040000 + 0X0311)), + + /// The legacy backup target was not supported by FileHistory + FHCFG_E_LEGACY_TARGET_UNSUPPORTED = unchecked((int)(0x80040000 + 0X0312)), + + /// The validation result of the legacy backup target was not supported + FHCFG_E_LEGACY_TARGET_VALIDATION_UNSUPPORTED = unchecked((int)(0x80040000 + 0X0313)), + + /// The legacy backup user was fully excluded from backups + FHCFG_E_LEGACY_BACKUP_USER_EXCLUDED = unchecked((int)(0x80040000 + 0X0314)), + + /// The legacy backup was not found + FHCFG_E_LEGACY_BACKUP_NOT_FOUND = unchecked((int)(0x80040000 + 0X0315)), + + // Error codes for the File History Service. (0x0600 - 0x06ff) + + /// Backups are blocked for the given configuration + FHSVC_E_BACKUP_BLOCKED = unchecked((int)(0x80040000 + 0x0600)), + + /// File History is not configured for the user + FHSVC_E_NOT_CONFIGURED = unchecked((int)(0x80040000 + 0x0601)), + + /// The specified configuration is disabled by the user + FHSVC_E_CONFIG_DISABLED = unchecked((int)(0x80040000 + 0x0602)), + + /// The specified configuration is disabled via Group Policy + FHSVC_E_CONFIG_DISABLED_GP = unchecked((int)(0x80040000 + 0x0603)), + + /// There is a fatal error with the specified configuration, backup cannot be even started + FHSVC_E_FATAL_CONFIG_ERROR = unchecked((int)(0x80040000 + 0x0604)), + + /// The specified configuration is undergoing rehydration + FHSVC_E_CONFIG_REHYDRATING = unchecked((int)(0x80040000 + 0x0605)), + } + /// /// /// The IFhConfigMgr interface allows client applications to read and modify the File History configuration for the user