我尝试使用 IUpdateSearcher 界面的搜索方法的 WUA API 检索 Windows Update。
我传递的搜索条件为“IsInstalled=1 或 IsPresent=1”。请在下面找到示例代码。
IUpdateSearcher* searcher;
ISearchResult* results;
/*
.
.
Code to initialize COM and get UpdateSearcher*/
.
.
*/
hRes = searcher->Search("IsInstalled=1 or IsPresent=1", &results);
我已经在MSDN中浏览了IsInstalled和IsPresent的定义(复制以供引用)。两者都谈论相似的事情。
IsPresent
When set to 1, finds updates that are present on a computer.
"IsPresent=1" finds updates that are present on a destination computer. If the update
is valid for one or more products, the update is considered present if it is installed
for one or more of the products."IsPresent=0" finds updates that are not installed
for any product on a destination computer.
IsInstalled
Finds updates that are installed on the destination computer.
"IsInstalled=1" finds updates that are installed on the destination computer.
"IsInstalled=0" finds updates that are not installed on the destination computer.
有人可以澄清一下它们到底有什么不同吗?
最佳答案
这里有一个更好的解释:http://msdn.microsoft.com/en-us/library/windows/desktop/aa386103(v=vs.85).aspx
以下是相关文字:
“备注
如果为一个或多个产品安装了更新,则视为存在更新。例如,如果某个更新同时适用于 Microsoft Office Word 和 Microsoft Office Excel,并且为其中一个或两个产品安装了更新,则 IsPresent 属性将返回 VARIANT_TRUE。
如果更新仅适用于一种产品,则 IsPresent 和 IsInstalled 属性是等效的。如果更新适用于所有产品,则视为已安装该更新。
如果 IsPresent 返回 VARIANT_TRUE 并且 IsInstalled 返回 VARIANT_FALSE,则可以为安装该更新的产品卸载该更新。”
关于windows - IUpdateSearcher的搜索条件中 "IsPresent=1"和 "IsInstalled=1"有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12844538/