ClearScript Library
ClearScript Library
ClearScript Library Reference
Microsoft.ClearScript
ExtendedHostFunctions Class
ExtendedHostFunctions Methods
arrType<T> Method
comType Method
lib Method
newComObj Method
type Method
typeLibEnums<T> Method

# ExtendedHostFunctionscomType Method

Imports a COM/ActiveX type.
Namespace: Microsoft.ClearScript
Assembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.5.0
Syntax
C#
VB
C++
F#
Copy

    public Object comType(
    	string progID,
    	string serverName = null
    )

    Public Function comType (
    	progID As String,
    	Optional serverName As String = Nothing
    ) As Object

    public:
    Object^ comType(
    	String^ progID,
    	String^ serverName = nullptr
    )

    member comType :
            progID : string *
            ?serverName : string
    (* Defaults:
            let _serverName = defaultArg serverName null
    *)
    -> Object

#### Parameters

progID String
  The programmatic identifier (ProgID) of the registered class to import.
serverName String (Optional)
  An optional name that specifies the server from which to import the type.

#### Return Value

Object
The imported COM/ActiveX type.
Remarks
The progID argument can be a class identifier (CLSID) in standard GUID format with braces (e.g., "{0D43FE01-F093-11CF-8940-00A0C9054228}").
Example
The following code imports the Scripting.Dictionary class and uses it to create and populate an instance. It assumes that an instance of ExtendedHostFunctions is exposed under the name "host" (see AddHostObject).
JavaScript
Copy

    var DictT = host.comType('Scripting.Dictionary');
    var dict = host.newObj(DictT);
    dict.Add('foo', 123);
    dict.Add('bar', 456.789);
    dict.Add('baz', 'abc');

See Also

#### Reference

ExtendedHostFunctions Class
Microsoft.ClearScript Namespace

Copyright © Microsoft Corporation. All rights reserved.

Send comments on this topic to Microsoft