[英]Unable to find an entry point named 'Reset' in DLL 'CIMWin32.dll'
[DllImport("CIMWin32.dll")] public static extern UInt32 Reset();
When I Am Calling This Method Then I Getting Exception当我调用这个方法然后我得到异常
Unable to find an entry point named 'Reset' in DLL 'CIMWin32.dll'
无法在 DLL 'CIMWin32.dll' 中找到名为 'Reset' 的入口点
I'm not sure what Reset
method of CIM
you want to import and invoke, but this is how you can call a method in VMI
.我不确定您要导入和调用的
CIM
什么Reset
方法,但这是您在VMI
调用方法的方式。 Install System.Management package via NuGet.通过 NuGet 安装System.Management包。 Then you need to create an instance of
ManagementClass
like below:然后你需要创建一个
ManagementClass
的实例,如下所示:
var NamespacePath = "\\\\.\\ROOT\\cimv2";
var ClassName = "CIM_LogicalDevice";
ManagementClass managementClass = new ManagementClass(NamespacePath + ":" + ClassName);
managementClass .InvokeMethod("Reset", null);
Of course in the code above, Reset
method is not implemented .当然在上面的代码中, 并没有实现
Reset
方法。 You can find your provider, class, and method in Microsoft Docs .你可以在Microsoft Docs 中找到你的提供者、类和方法。 For eg above, I tried to call the
Reset
method of CIM_LogicalDevice
class.例如上面,我尝试调用
CIM_LogicalDevice
类的Reset
方法。
In the requirement section, you can see the namespace.在需求部分,您可以看到命名空间。
If you look for the more complicated example of how to invoke WMI class methods, take a look on this example on Microsoft Docs: https://docs.microsoft.com/en-us/configmgr/develop/core/clients/programming/how-to-call-a-wmi-class-method-by-using-system.management如果您要查找有关如何调用 WMI 类方法的更复杂示例,请查看 Microsoft Docs 上的此示例: https : //docs.microsoft.com/en-us/configmgr/develop/core/clients/programming/ how-to-call-a-wmi-class-method-by-using-system.management
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.