我试图检查是否启用了 Windows 更新。我在 Windows 7 x64 Ultimate 上添加了对 c:\windows\system32\wuapi.dll 的引用并编写了这段代码
using WUApiLib;
public Boolean IsWindowsUpdateEnabled()
{
var updates = new AutomaticUpdatesClass();
return updates.ServiceEnabled;
}
代码无法构建。我收到以下错误:
错误 1 类型“WUApiLib.AutomaticUpdatesClass”没有定义构造函数
错误 2 无法嵌入互操作类型“WUApiLib.AutomaticUpdatesClass”。请改用适用的接口。
错误 3“WUApiLib.AutomaticUpdatesClass”不包含“ServiceEnabled”的定义,并且找不到接受“WUApiLib.AutomaticUpdatesClass”类型的第一个参数的扩展方法“ServiceEnabled”(您是否缺少 using 指令或程序集引用?)