Deploying the SDK Platform in C #

I have read the SDK framework samples and the examples are in VB.NET. I am using C #, so I was wondering how can I replicate this string in C #?

Set   Installer   =   CreateObject("WindowsInstaller.Installer")   

      

Thank.

+1


source to share


4 answers


using System.Runtime.InteropServices;

Type InstallerType;
object Installer;

InstallerType= Type.GetTypeFromProgID("WindowsInstaller.Installer");
Installer= Activator.CreateInstance(InstallerType);

      



+2


source


It looks like VB6 / VBScript, not VB.NET :) But I could be wrong.

Parameters:



  • Find the .NET framework equivalent of the WindowsInstaller.Installer object and use that.
  • Use Activator.CreateInstance () . But don't expect a strongly typed response.
  • Add a reference to the WindowsInstaller.Installer COM object and VS will create a strongly typed interface that will allow you to instantiate in C #.
+1


source


Go to add a link, select the COM tab and select "WindowsInstaller". ('Interop.WindowsInstaller')

Add : using WindowsInstaller;

Type type = Type.GetTypeFromProgID("WindowsInstaller.Installer");
Installer msi = (Installer)Activator.CreateInstance(type);

//ur code: -
foreach (string productcode in msi.Products)
{
//ur code
}

      

+1


source


This VBScript I think.

You will be better off looking for whatever you are trying to do within the .NET framework. It has a rich installer library that should make this easier. Don't try to use any COM object because this is what you found. Work within the framework that you are in.

0


source







All Articles