ComObjGet

Returns a reference to an object provided by a COM component.

ComObject := ComObjGet(Name)

Parameters

Name

Type: String

The display name of the object to be retrieved. See MkParseDisplayName (MSDN) for more information.

Return Value

Type: Object

This function returns a reference to a COM object.

Error Handling

An exception is thrown on failure.

Related

ComObjCreate, ComObjActive, ComObjConnect, ComObjQuery, CoGetObject (MSDN)

Examples

#1: Press Shift+Escape to show the command line which was used to launch the active window's process.

+Esc::
{
    pid := WinGetPID("A")
    ; Get WMI service object.
    wmi := ComObjGet("winmgmts:")
    ; Run query to retrieve matching process(es).
    queryEnum := wmi.ExecQuery(""
        . "Select * from Win32_Process where ProcessId=" . pid)
        ._NewEnum()
    ; Get first matching process.
    if queryEnum[proc]
        MsgBox(proc.CommandLine, "Command line", 0)
    else
        MsgBox("Process not found!")
    ; Free all global objects (not necessary when using local vars).
    wmi := queryEnum := proc := ""
}
; Win32_Process: http://msdn.microsoft.com/en-us/library/aa394372.aspx