WindowsUpdateが有効になっているかどうかを確認しようとしました。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ディレクティブまたはアセンブリ参照がありませんか?)