Creating COM Library

Now the COM object is available to be called by its ProgID.

Example

Example class for COM:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
using System.Runtime.InteropServices;
 
namespace MyLib
{
 
    [InterfaceType(ComInterfaceType.InterfaceIsDual), Guid("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")]
    public interface IMyLauncher
    {
        void launch();
    }
 
    [ClassInterface(ClassInterfaceType.None), Guid("YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYY"), ProgId("MyLib.MyLauncher")]
    public class MyLauncher: IMyLauncher
    {
        private string path = null;
 
        public void launch()
        {
            Console.WriteLine("Hello, World, from a COM object");
 
        }
 
    }
}

Example how to call COM object using VB script:

set obj = createObject("PSMyLib.PSMyLauncher") obj.launch()

Output:

Hello, World, from a COM object
References