Итак, у меня есть этот код, и я сталкиваюсь с некоторыми проблемами, которые я до сих пор не смог решить:
Везде, где есть Параметры, то есть "CreateRestorePoint"
, или параметры inParams
, Я получаю зеленое волнистое подчеркивание, которое говорит использовать (например) "NameOf(CreateRestorePoint) instead of specifying the program element name"
.
Однако, если я так делаю или оставляю это, я получаю ту же ошибку:
System.ArgumentOutOfRangeException: 'Specified argument was out of the range of valid values. Parameter name: path'
Код:
Public Function CreateRestorePoint(Description As String, EventType As Integer, RestorePointType As Integer) As Integer
Try
Dim classInstance As New ManagementObject("root\DEFAULT", "SystemRestore", Nothing)
' Obtain [in] parameters for the method
Dim inParams As ManagementBaseObject = classInstance.GetMethodParameters("CreateRestorePoint")
' Add the input parameters
inParams("Description") = Description
inParams("EventType") = EventType
inParams("RestorePointType") = RestorePointType
' Execute the method and obtain the return values
Dim outParams As ManagementBaseObject = classInstance.InvokeMethod("CreateRestorePoint", inParams, Nothing)
' List outParams
Debug.Print("Out parameters: ")
Debug.Print("ReturnValue: {0}", outParams("ReturnValue"))
CreateRestorePoint = 1
Catch err As ManagementException
Debug.Print(String.Format("An error occurred while trying to execute the WMI method: {0}", err.Message))
End Try
Return CreateRestorePoint
End Function
Вот как я вызываю функцию:
Dim CRP As New JSEWindowsRestore.WindowsRestoreFunctions
CRP.CreateRestorePoint(String.Format("Test Restore Point: {0}", DateTime.Now), 100, 12)
Кто-нибудь определит проблему?