ComObjFlags() [v1.0.96.00+]

Retrieves or changes flags which control a COM wrapper object's behaviour.

Flags := ComObjFlags(ComObject , NewFlags, Mask)



A COM wrapper object.


New values for the flags identified by Mask, or flags to add or remove.


A bitmask of flags to change.


All of ComObject's flags (after applying NewFlags, if specified).


Currently only affects SafeArrays. If this flag is set, the SafeArray is destroyed when the wrapper object is freed. Since SafeArrays have no reference counting mechanism, if a SafeArray with this flag is assigned to an element of another SafeArray, a separate copy is created.

General Remarks

If Mask is omitted, NewFlags specifies the flags to add (if positive) or remove (if negative). For example, ComObjFlags(obj, -1) removes the F_OWNVALUE flag. Do not specify any value for Mask other than 0 or 1; all other bits are reserved for future use.


ComObjActive, ComObjArray


; Example: Check for the presence of the F_OWNVALUE flag.

arr := ComObjArray(0xC, 1)
if ComObjFlags(arr) & 1
    MsgBox arr will be automatically destroyed.
    MsgBox arr will not be automatically destroyed.
; Example: Change array-in-array behaviour.

arr1 := ComObjArray(0xC, 3)
arr2 := ComObjArray(0xC, 1)
arr2[0] := "original value"
arr1[0] := arr2         ; Assign implicit copy.
ComObjFlags(arr2, -1)   ; Remove F_OWNVALUE.
arr1[1] := arr2         ; Assign original array.
arr1[2] := arr2.Clone() ; Assign explicit copy.
arr2[0] := "new value"
for arr in arr1
    MsgBox % arr[0]

arr1 := ""
; Not valid since arr2 == arr1[1], which has been destroyed: 
;  arr2[0] := "foo"