Loop through System::Object

I am trying to translate some VB.Net code into C++ Specifically:

Dim installer As Object
installer = CreateObject("WindowsInstaller.Installer")
Dim products As Object = installer.Products
For Each strProductCode As String In products
Try
Dim strProductName As String = installer.ProductInfo(strProductCode, "InstalledProductName")
If strProductName.Contains(InstalledProductNameStr) = True Then
retStr = strProductCode
End If
Catch ex As Exception
End Try
Next

Object ^installer = nullptr;
InstallerPtr pInstaller("WindowsInstaller.Installer");
Object ^products = pInstaller->Products;
for each (String ^strProductCode in products)
{
try
{
String ^strProductName = installer->ProductInfo(strProductCode, "InstalledProductName");
if (strProductName->Contains(InstalledProductNameStr) == true)
{
retStr = strProductCode;
}
}
catch (Exception ^ex)
{
}
which doesn't work. I get an error saying "error C3285: for each statement cannot operate on variables of type 'System::Object ^'"

So my question is (a) is there a better way to translate that vb code and (b) for my education, how can you loop through an object (I know it is something to do with making it Ienumerable, but I am not sure how)
Topic archived. No new replies allowed.