a4u wrote:
Is there a reason you chose to return a pointer, as opposed to a wrapped Com Object?
The first and probably only thing you (the hypothetical advanced user) would need to do with the wrapper object is retrieve the pointer from within it. If you can figure out how to call interface functions correctly, you are presumably capable of releasing the pointer when it is appropriate - or in the less efficient case, wrapping it to be released automatically. If the method you are calling returns an interface pointer, you'd need to handle it the same way. Likewise for ComObjUnwrap in AutoHotkey_L, but not in Sean's private build.
Quote:
In regards to the previous question, if I wrap the pointer with ComObj(9,ptr,1), would I still have to Release the object?
No.
Quote:
If not, wouldn't that be the resolution to Sean's concern about leaking Com Objects?
I feel that it's not my place to answer that question.
However, it may be that I haven't adequately explained my motivation for opposing Sean's implementation of ComObjEnwrap/Unwrap. I firmly believe that any raw COM interface pointer made accessible to the script should be treated according to the
COM reference counting rules. Anyone dealing with external COM code via DllCall will need to learn them eventually, and inconsistencies only make this more difficult. These functions are intended for advanced users, not VBScript converts.
ComObjValue is the exception, since it interprets the wrapper object's contents as a 64-bit integer regardless of the actual type. It can be equated to
variant.llVal. By contrast, ComObjUnwrap can be equated to
ComObjQuery(ComObject, IID_IDispatch). Built-in SafeArray support made ComObjValue redundant for my original purpose, which was to copy the value from an object created by ComObjParameter into a script-built SafeArray (of parameters to pass to the CLR). The improvements to CLR support in v1.0.96.00 make it further redundant.