title: Visual C++, Windows Update Interface (IUpdate) <wuapi.h>, get_MsrcSeverity
body: <p>I'm probably just blind, but I cannot see any errors here (and I am looking on this issue already for days now...)</p>
  
  <p>I am trying to get the Patch Priority (Severity) from the Windows Update Interface using the following piece of code in Visual Studio:</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;wuapi.h&gt;
  #include &lt;iostream&gt;
  #include &lt;ATLComTime.h&gt;
  #include &lt;wuerror.h&gt;
  
  using namespace std;
  
  
  int _tmain(int argc, _TCHAR* argv[])
  {
  
  
       HRESULT hr;
      hr = CoInitialize(NULL);
  
      IUpdateSession* iUpdate;
      IUpdateSearcher* searcher;
      ISearchResult* results;
      BSTR criteria = SysAllocString(L"IsInstalled=0");
  
      hr = CoCreateInstance(CLSID_UpdateSession, NULL, CLSCTX_INPROC_SERVER, IID_IUpdateSession, (LPVOID*)&amp;iUpdate);
      hr = iUpdate-&gt;CreateUpdateSearcher(&amp;searcher);
  
      wcout &lt;&lt; L"Searching for updates ..."&lt;&lt;endl;
      hr = searcher-&gt;Search(criteria, &amp;results); 
      SysFreeString(criteria);
  
      switch(hr)
      {
      case S_OK:
          wcout&lt;&lt;L"List of applicable items on the machine:"&lt;&lt;endl;
          break;
      case WU_E_LEGACYSERVER:
          wcout&lt;&lt;L"No server selection enabled"&lt;&lt;endl;
          return 0;
      case WU_E_INVALID_CRITERIA:
          wcout&lt;&lt;L"Invalid search criteria"&lt;&lt;endl;
          return 0;
      }
  
      IUpdateCollection *updateList;
      IUpdateCollection *bundledUpdates;
      IUpdate *updateItem;
      IUpdate *bundledUpdateItem;
      LONG updateSize;
      LONG bundledUpdateSize;
      BSTR updateName;
      BSTR severity;
  
      results-&gt;get_Updates(&amp;updateList);
      updateList-&gt;get_Count(&amp;updateSize);
  
      if (updateSize == 0)
      {
          wcout &lt;&lt; L"No updates found"&lt;&lt;endl;
      }
  
      for (LONG i = 0; i &lt; updateSize; i++)
      {
          updateList-&gt;get_Item(i,&amp;updateItem);
          updateItem-&gt;get_Title(&amp;updateName);
  
          severity = NULL;
          updateItem-&gt;get_MsrcSeverity(&amp;severity);
          if (severity != NULL) 
          {
              wcout &lt;&lt; L"update severity: " &lt;&lt; severity &lt;&lt; endl;
          }
  
          wcout&lt;&lt;i+1&lt;&lt;" - " &lt;&lt; updateName &lt;&lt; endl;
  
          // bundled updates
          updateItem-&gt;get_BundledUpdates(&amp;bundledUpdates);
          bundledUpdates-&gt;get_Count(&amp;bundledUpdateSize);
  
          if (bundledUpdateSize != 0) 
          {
              // iterate through bundled updates
              for (LONG ii = 0; ii &lt; bundledUpdateSize; ii++) 
              {
                  bundledUpdates-&gt;get_Item(ii, &amp;bundledUpdateItem);
                  severity = NULL;
                  bundledUpdateItem-&gt;get_MsrcSeverity(&amp;severity);
                  if (severity != NULL) 
                  {
                      wcout &lt;&lt; L" bundled update severity: " &lt;&lt; severity &lt;&lt; endl;
                  }
              }
  
          }
  
      }
  
      ::CoUninitialize();
      wcin.get();
  
  
      return 0;
  }
  </code></pre>
  
  <p>So here's the issue: <code>updateItem-&gt;get_MsrcSeverity(&amp;severity);</code> is not returning anything. If I catch the result code with an <code>HRESULT</code> it always returns <code>S_OK</code>.</p>
  
  <p>Link to MSDN IUpdate MsrcSeverity: <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa386906(v=vs.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/desktop/aa386906(v=vs.85).aspx</a></p>
  
  <p>Can you see what I am doing obviously wrong or is the <code>get_MsrcSeverity</code> function currently broken?</p>
  
  <p>@EDIT: Changed the code to iterate through "BundledUpdates" as suggested.</p>
  
  <p>@EDIT2: the code now outputs the severity value of the <code>updateItem</code> as well as the <code>bundledUpdatesItem</code>, but it's always <code>NULL</code>.</p>
  
  <p>I also know there is one important update waiting for my computer - regarding to Windows Update in the control panel. It is KB2858725.</p>
  
  <p>@EDIT3: Okay, it turns out, KB2858725 is no security update and therefore has no severity rating by Microsoft. But how does Microsoft Windows Update now categorize the updates in "important" and "optional" like you can see it in control panel's update?</p>
  
  <p>Thank you for any hints!
  // Markus</p>