Thank you jethrow and Coco for taking time to help me with this. It is not something I think I could figure out on my own.
It looks like the header file I need to refer to is
oaidl.h. Are there any others I will need? I have needed
winuser.h for some constants (e.g. to use with
SendMessage) in the past.
I am still having a hard time understanding most of
IsMemberOf.
The nested
NumGets,
ComObjValue, and pointer arithmetic are for retrieving the address of the method to call? First get the address of the COM object, then get its vtable, then get the method's address?
1*p would normally be equivalent to just
p. Is this used to force a value into what I have heard called "pure numeric" format?
Is it safe to assume the write to
p occurs before the read in the same call? Is the order of evaluation of arguments in AutoHotkey always from left to right, as in most high-level programming languages that define it, instead of right to left as it often is in unoptimized C and C++, or unpredictable as it often is in optimized C and C++?
This part confuses me
VarSetCapacity(iid,16,0)*0+&iid.
I am sure
VarSetCapacity is being used to reserve space. I guess that is for an array of names, based on the
GetIDsOfNames documentation. How does a single name become an array in this case?
Where does
iid come from?
Why a
16 for the capacity? How do we know that will always be enough?
I assume the
0 fill byte is for null termination of the string.
Is the result of
VarSetCapacity being multiplied by
0 just to hide its existence in the expression, since it should always result in 0?
Based on Microsoft's documentation I would think the third argument would be the count of names, but it seems to be the name itself here?
Then again, it seems to show 5 arguments, while there are 6 here. I am not counting the pointer to the method.
From trying to compare to Coco's explanation it looks like the extra argument is for the pointer to
IDispatch. Is that the implicit "this" argument for the method?
I am guessing the remaining arguments have to do with the locale and allocating space for the "out variable". They are hard coded. How do we know they are always correct?
The documentation says
GetIDsOfNames returns
S_OK for success, which seems to be defined in
winerror.h (success is defined as an error in Windows...) as 0. The
=0 was supposed to be
==0? It was changed to that in Coco's version, and I can see the purpose if that was what was intended.
Why is
1 being added to the "out variable" before it is
logical anded with the
GetIDsOfNames result? I think that would always make it
true unless we were working with -1 and 0.
Do I need to worry about doing some sort of cleanup as Lexikos mentions (
ObjRelease)?
It seems I need to read about the fields and methods of
IDispatch and
ITypeInfo. Is there anything else I should read about for this task?
I still do not know why the names for
Shell.Application members are null. I have read about
typelibs sometimes needing to be loaded. Could that be it? If so, do either of you know how I would correct it? I found a
LoadTypeLib function.
Do either of you know how I would get the scriptable COM object method equivalent of
MinParams,
MaxParams, and
IsVariadic? I know scriptable COM object methods have required and optional parameters, with the same restrictions as AutoHotkey. I do not know if they can be variadic.
I saw these comments in jethrow's code (
iTypeInfo - Get info from TypeAttr Struct - Enum Com Members)
Code: Select all
; Args := NumGet(FuncDesc+0, 36, "short") ; get Num of Args
; Opt := NumGet(FuncDesc+0, 38, "short") ; get Num of Opt Args