IComTypeLibrary Copy link to this sectionLink to this section copied!

DeclarationCopy link to this sectionLink to this section copied!

IComTypeLibrary: IDispatch

OverviewCopy link to this sectionLink to this section copied!

This interface is meant to allow you to specify the information that will be placed in the registry during the Type Library's registration process.

PropertiesCopy link to this sectionLink to this section copied!

String Guid - Gets the GUID of the type library.

IFile File - Gets the the type library file (.tlb).

String Language - Gets or sets the type library's language.

String Version - Gets or sets the type library's version.

IFolder Directory - Gets or sets the directory that contains the Help file for the type library.

UINT Cost - Gets or sets the cost, in bytes, associated with the type library properties.

String RegistryPath - Gets or sets the registry location where the Type Library is registered. For type libraries defined through MSI TypeLib table this location is read only.
Supported values: HKEY_CLASSES_ROOT\TypeLib, HKEY_CURRENT_USER\Software\Classes\TypeLib, HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib, HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\TypeLib.

ExamplesCopy link to this sectionLink to this section copied!

 $advinst  = new-object -comObject "AdvancedInstaller"
    $proj     = $advinst.CreateProjectS("architect")

    $clsid_id       = "{4819544F-6FAF-4553-86C3-7B58F73BA4D0}"
    $interface_GUID = "{E4C611D8-6DA8-48F7-8AD8-D6CB6D64293C}"
    $typelib_GUID   = "{37687F89-8603-4E42-A5F4-4FBAB011D5F3}"

        # add new class
    $file   = $proj.FilesComponent.AddFileS("appdir", "D:\MyApp.exe")
   

    $new_class = $proj.ComComponent.NewClass("{222AD1AD-EB4D-4859-A11E-B5EC859CC0BB}",$file)

    # edit ActiveX
    $new_class.ActiveX.IsActivXControl  = $true
    $new_class.ActiveX.IsProgrammable   = $true
    $new_class.ActiveX.IsInsertable     = $true
    $new_class.ActiveX.BitmapPath       = "$($file.FullPath)"
    $new_class.ActiveX.BitmapResourceId = 1
    $new_class.ActiveX.Default          = 4
    $new_class.ActiveX.Content          = 131473
    $new_class.ActiveX.Thumbnail        = 44456
    $new_class.ActiveX.Icon             = 778
    $new_class.ActiveX.Docprint         = 89
    $new_class.ActiveX.Extensions       = ".test,.aaa"
    $new_class.ActiveX.AddDotNetCategory()
    $new_class.ActiveX.AddSafeForInitializingCategory()
    $new_class.ActiveX.AddSafeForScriptingCategory()
    $new_class.ActiveX.AddCategory("{7DD95802-9882-11CF-9FA9-00AA006C42C4}")

    # edit AppId
    $new_class.AppId.AppId                = "{10000000-0000-0000-0000-000000000001}"
    $new_class.AppId.RemoteServerToLaunch = "server name"
    $new_class.AppId.LocalService         = "service name"
    $new_class.AppId.DllSurrogate         = "aaa"
    $new_class.AppId.ActivateAtStorage    = $true
    $new_class.AppId.RunAsInteractiveUser = $true

    $new_class.ThreadingModel = "Both"
    $progId = $proj.FileAssociations.NewProgId()
    $new_class.ProgId                   =  $progId

    $new_class.VersionIndependentProgId = "Test.ProgId.1"
    $new_class.Description              = "new description for this class"
    $new_class.Version                  = "1.2.3"
    $new_class.TypeLibraryId            = "{37687F89-8603-4E42-A5F4-4FBAB011D5F3}"
    $new_class.IconPath                 = "$currentPath\resources\resources-powershell\sample.exe"
    $new_class.DefaultInProcHandler     = "2"
    $new_class.Argument                 = "/test"
    $new_class.HasRelativePath          = $true

    # add new interface
    $new_interface = $proj.ComComponent.NewInterface("{00000000-674B-41F9-9EC2-4925BF949F12}", "TestInterface") 
    $new_interface.NumberOfMethods = 3
    $new_interface.BaseInterface = "{20000000-0000-0000-0000-000000000000}"
    $new_interface.CLSID16       = "{16000000-0000-0000-0000-000000000000}"
    $new_interface.CLSID32       = "{32000000-0000-0000-0000-000000000000}"
    $new_interface.TypeLibId     = "{50000000-0000-0000-0000-000000000000}"
    $new_interface.TypeLibVersion = "2.5"
    $new_interface.RegistryPath   = "HKEY_CURRENT_USER\Software\Classes\Interface"

    # add new type librabry
    $new_typelib             = $proj.ComComponent.NewTypeLibrary($file)
    $new_typelib.GUID        = "{23487F89-8603-4E42-A5F4-4FBAB011D5F3}"
    $new_typelib.Language    = "bg"
    $new_typelib.Version     = "1.2"
    $new_typelib.Description = "new description for typelib"
    $new_typelib.Cost        = 3