<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Enumerate installed patches for a given product using MSI API</Title>
      <Shortcut>EnumerateinstalledpatchesforagivenproductusingMSIAPI</Shortcut>
      <Description>Enumerate installed patches for a given product using MSI API [C++]</Description>
      <Author>Yan Michalevsky</Author>
      <HelpUrl>/PreviewSnippet.aspx?SnippetID=1415c971-3b4b-4e1a-9880-a2eaaa090599</HelpUrl>
      <SnippetTypes>
        <SnippetType>SurroundsWith</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Code Language="C++"><![CDATA[static void getInstalledPatchesList(const CString& productCode,								        CAtlList< CString >* patchesList)
{
	UINT retval;
	UINT patchIndex = 0;
	TCHAR patchGuidBuffer[MAX_PRODUCT_CODE_LEN] = _T("");
	TCHAR transformsBuff[100] = _T("");
	DWORD transformsBuffSize = sizeof(transformsBuff)/sizeof(transformsBuff[0]);
	
	do {
		memset(patchGuidBuffer, 0, sizeof(patchGuidBuffer));
		memset(transformsBuff, 0, sizeof(transformsBuff));
		transformsBuffSize = sizeof(transformsBuff)/sizeof(transformsBuff[0]);
		
		retval = MsiEnumPatches(productCode, patchIndex, patchGuidBuffer,
  				          transformsBuff, &transformsBuffSize);
		if (ERROR_SUCCESS == retval) {
			patchesList->AddTail(CString(patchGuidBuffer));
			++patchIndex;
		}
	} while (ERROR_SUCCESS == retval);
} //end of getInstalledPatchesList]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>