Click or drag to resize

ExtendedHostFunctionsnewComObj Method

Creates a COM/ActiveX object of the specified type.

Namespace:  Microsoft.ClearScript
Assembly:  ClearScript.Core (in ClearScript.Core.dll) Version: 7.2.3
Syntax
public Object newComObj(
	string progID,
	string serverName = null
)

Parameters

progID
Type: SystemString
The programmatic identifier (ProgID) of the registered class to instantiate.
serverName (Optional)
Type: SystemString
An optional name that specifies the server on which to create the object.

Return Value

Type: Object
A new COM/ActiveX object of the specified type.
Remarks
The progID argument can be a class identifier (CLSID) in standard GUID format with braces (e.g., "{0D43FE01-F093-11CF-8940-00A0C9054228}").
Examples
The following code creates a Scripting.FileSystemObject instance and uses it to list the drives on the local machine. It assumes that an instance of ExtendedHostFunctions is exposed under the name "host" (see AddHostObject).
JavaScript
var fso = host.newComObj('Scripting.FileSystemObject');
var ConsoleT = host.type('System.Console');
for (en = fso.Drives.GetEnumerator(); en.MoveNext();) {
    ConsoleT.WriteLine(en.Current.Path);
}
See Also