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.4.5
Syntax
public Object newComObj(
	string progID,
	string serverName = null
)

Parameters

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

Return Value

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}").
Example
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