2

I am a newbie in C++ and currently working to get Windows Hotfix/Patch information in C++ DLL.

I have evaluated the following ways:

  1. By executing a sub process in C++ code and running wmic qfe get and read all the data.
  2. By using the C++ APIs to initialize COM, Connect to Wbem and execute select * from win32_quickfixengineering query.

Apart from above two methods,

Is there any direct Windows API that does all the job for me and gives the list of KB Info currently installed on the machine?

TechyHarry
  • 301
  • 2
  • 8
  • 25
  • 1
    The list of KB's currently installed on the machine is not useful. For example, if you want to know if the fix for Q1234 is installed, the answer might be "yes" even though KB1234 is not in the list of installed KBs. The fix might be in a roll-up or service pack. The correct answer is not to query the list of QFEs and look for 1234 but rather to ask WU whether QFE 1234 is needed. – Raymond Chen Oct 08 '12 at 14:50
  • Thanks Chen for fast reply. I exactly need the KB list what qfe get gives. I am aware of the scenario where some KBs part of service packs, we can get that information from OS Information. If any APIs written that perform like qfe get, I can directly use in code instead of me writing entirely from scratch. – TechyHarry Oct 08 '12 at 16:37
  • You haven't explained what you're going to use this information for, so it's not clear whether this is the correct approach. At any rate, you can always [program directly to WMI](http://msdn.microsoft.com/en-us/library/windows/desktop/aa390418). That's all that WMIC does. – Raymond Chen Oct 08 '12 at 16:57
  • The information is used to know the patch information of the machine. – TechyHarry Oct 08 '12 at 18:12

1 Answers1

2

You can use the Windows Update Agent API and the IUpdateSearcher interface.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • Hi RRUZ, thanks for the reply. I looked at IUpdateSearcher interface, it is similar to executing select * from win32_quickfixengineering and iterate through results. Even executing query and IUpdateSearcher both are done through COM. Can you please throw some light on difference between executing query and using IUpdateSearcher? Which is better implementation, faster, and works across all Windows platforms? – TechyHarry Oct 08 '12 at 16:44
  • @HareeshSarma, sometime ago I wrote an [article](https://theroadtodelphi.wordpress.com/2011/03/02/search-for-installed-windows-updates-using-delphi-wmi-and-wua/) about this topic which can help you to understand how it works, the code is in Delphi but can be easily translated to C++ – RRUZ Oct 08 '12 at 16:58
  • Great. Awesome article. I will try converting that to C++. Some more questions. Does WUA gives all the update and hotfix info in all versions of windows 32 bit and 64 bit and any specific coding required for 64 bit? And this WUA works for all server Windows from 2000 to 2008 R2 and Client Windows XP to Windows 8? – TechyHarry Oct 08 '12 at 18:24
  • The WUA API works in the exact same way in X86 and 64 bits Windows, And is available since Windows 2000 Professional with SP3 in Desktop and server windows editions. – RRUZ Oct 08 '12 at 19:50
  • Hi RRUZ, I have gone through the IUpdateSearcher interface and implemented sample code to get KB Info. But I found couple of more interfaces IUpdateSearcher2 and IUpdateSearcher3, which has some additional options to search for user based approach. Could you please explain where exactly this IUpdateSearcher(x) interface searches in the Windows machine to pick up the info? Does it look for the same registry paths which wmic qfe get looks or any other special file system that has Update info? – TechyHarry Oct 09 '12 at 07:54
  • Windows Update API doesn't return all the installed patches, specially if the patch was installed manually and not via the Windows Updates UI – AHS Apr 26 '19 at 17:42