title: MsiEnumProductsEx Not Working
body: <p>I have the following application, to check installed programs in a system:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;Msi.h&gt;
  #include &lt;Windows.h&gt;
  
  using namespace std;
  
  void main()
  {
      UINT ret;
      DWORD dwIndex = 0;
      DWORD dwContext = MSIINSTALLCONTEXT_ALL;
      char szInstalledProductCode[39] = {0};
      char szSid[128] = {0};
      const char* szUserSid = "s-1-1-0";
      DWORD cchSid;
      MSIINSTALLCONTEXT dwInstalledContext;
  
      do
      {
          memset(szInstalledProductCode, 0, sizeof(szInstalledProductCode));
          cchSid = sizeof(szSid)/sizeof(szSid[0]);
  
          ret = MsiEnumProductsEx(
              NULL,           // all the products in the context
              szUserSid,  // i.e.Everyone, all users in the system
              dwContext,
              dwIndex,
              szInstalledProductCode,
              &amp;dwInstalledContext,
              szSid,
              &amp;cchSid
          );
  
          if(ret == ERROR_SUCCESS)
          {
              char* name = MsiGetProductInfoEx (
                  szInstalledProductCode,
                  cchSid == 0 ? NULL : szSid,
                  dwInstalledContext,
                  INSTALLPROPERTY_INSTALLEDPRODUCTNAME
              );
  
              char* version = MsiGetProductInfoEx (
                  szInstalledProductCode,
                  cchSid == 0 ? NULL : szSid,
                  dwInstalledContext,
                  INSTALLPROPERTY_VERSIONSTRING
              );
  
              cout &lt;&lt; name &lt;&lt; endl;
              cout &lt;&lt; "  - " &lt;&lt; version &lt;&lt; endl;
  
              dwIndex++;
          }
  
      } while(ret == ERROR_SUCCESS);
  }
  </code></pre>
  
  <p>I am using Microsoft Visual C++ Express 2010. The application is MBCS. In studio, these four things are in red (error):</p>
  
  <ul>
  <li><code>MSIINSTALLCONTEXT_ALL</code></li>
  <li><code>MSIINSTALLCONTEXT</code></li>
  <li><code>MsiEnumProductsEx</code></li>
  <li><code>MsiGetProductInfoEx</code></li>
  </ul>
  
  <p>I linked the Msi.lib (Project properties -> Linker ->  Input -> Additional Dependencies). I am just trying to figure out how <code>MsiEnumProductsEx</code> function works.  I know there are other questions around, but I just can't understand why it isn't working because I think that I have everything for the functions to be available, at least. Thanks!</p>