2012-01-20 126 views
0

我想通过.Net从Windows Update API获取LastInstallationSuccessDate和LastSearchSuccessDate。我可以得到IAutomaticUpdates2.Results,但其中包含的这两个属性为空。为什么他们的日期不像文档状态?为什么WUApiLib.AutomaticUpdates Results.WUApiLib.AutomaticUpdates为空?

class Program 
{ 
    static void Main(string[] args) 
    { 
     WUApiLib.IAutomaticUpdates2 auc = new WUApiLib.AutomaticUpdates(); 
     Console.WriteLine(auc.Results.LastInstallationSuccessDate); 
     Console.WriteLine(auc.Results.LastSearchSuccessDate); 
    } 
} 
+0

它正在使用Windows 7 x64,但不能在Windows XP x86上使用。 –

+0

我会猜测WUApiLib支持仅限于Vista和更高版本。 –

+0

在这个网站的简单搜索让我发现这个讨论:http://stackoverflow.com/questions/5690615/c-sharp-windows-update-api-wuapilib –

回答

0

虽然LastInstallationSuccessDate和LastSearchSuccessDate在COM接口存在他们在Windows XP不支持,总是返回null。

同样,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\InstallLastSuccessTimeHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Detect\LastSuccessTime注册表值在Windows XP中不存在。

似乎可以使用解析%windir%\ SoftwareDistribution \ ReportingEvents.log来近似此功能,但应该考虑性能,因为该文件可能变得非常大。