How to call GetIDsOfNames for resolve Method ID for few methods? It works fine for resolve only one or first-one MethodID.
My code right now:
pDisp : IDispatch;
intResult : HResult;
NameCount : integer;
DispIDs : array [0..2] of Integer;
WideNames : array of WideString;
I : Integer;
Names, Src : PAnsiChar;
N : array [0..2] of PAnsiChar;
begin
pDisp := CreateOleObject (edtPrgID1.Text);
if VarIsNull (pDisp) or VarIsEmpty (pDisp) then
Exit;
//-=-
NameCount := 3;
Names := 'doF4' + #0 + 'doF5' + #0 + 'doF6' + #0;
//-=-
SetLength (WideNames, NameCount);
Src := Names;
for I := 0 to NameCount - 1 do
begin
if I = 0 then
WideNames [I] := UTF8ToWideString (Src)
else
WideNames [NameCount - I] := UTF8ToWideString (Src);
Inc (Src, StrLen (Src) + 1);
end;
intResult := pDisp.GetIDsOfNames (GUID_NULL, WideNames, NameCount, LOCALE_SYSTEM_DEFAULT, @DispIDs);
I am trying to work with my own ActiveX COM (DLL) component. All method 100% exists and valid.
I am not sure why, but in DispIDs I always get result only for first method (in my sample “doF4”), for all other methods I get -1. So, DispIDs after execution pDisp.GetIDsOfNames looks like (205, -1, -1).
You have to call GetIDsOfNames() once for each method. The documentation explains why in its description of the output parameter:
The first element represents the member name. The subsequent elements represent each of the member's parameters.
So to get IDs of three members, rather than one member and two of its arguments, you need to call it three times.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With