GetIDsOfNames help 
Author Message
 GetIDsOfNames help

Hello,
I'm trying to dinamically read a COM objects' methods and parameters list at
run time, in order to later place an Invoke() call.

Using GetIDsOfNames, I can get the method's DISPID, which I can then use in
Invoke (and this is working); however, reading documentation for
GetIDsOfNames lets me understand I should be able to extract the method's
parameters list, with a single call to GetIDsOfNames in which I am to pass
an array of names (right?).

I tried the following, but am not able to understand how to extract info
about parameters (I just want parameters names, so that I can later parse
values into a DISPPARAMS structure):

DISPID dispidParam;
OLECHAR FAR* szParam = {L"myMethod\0szFirstParam"};

hresult = pdisp->GetIDsOfNames( IID_NULL, &szParam, 1, LOCALE_USER_DEFAULT,  
&dispidParam);

"myMethod" is the method name, while "szFirstParam" is the first (and only)
parameter name.
Not sure this is ok.. I actually tested much with:

DISPID dispidParam;
OLECHAR FAR* szParam = L"myMethod";

hresult = pdisp->GetIDsOfNames( IID_NULL, &szParam, 1, LOCALE_USER_DEFAULT,  
&dispidParam);

assuming GetIDsOfNames should return info for the method and its parameters;
however, dispidParam appears to hold a DISPID for the method only (later
call to Invoke is successfull).

Can anybody point me to the right direction?
Thank you,
AL.



Tue, 21 Sep 2004 19:26:56 GMT  
 GetIDsOfNames help
Make it

OLECHAR* names[] =
{
    OLESTR("myMethod"),
    OLESTR("szFirstParam")

Quote:
};

DISPID dispids[2];

hresult = pdisp->GetIDsOfNames( IID_NULL, names, 2, LOCALE_USER_DEFAULT,
dispids);

But really, you do not need DISPIDs of the parameters to call Invoke.
You can always pass parameters by position. Named parameters are needed
in some languages - e.g. VB allows syntax similar to

MethodName paramName1:123 paramName2:"abc"

where the caller does not know the number and order of parameters to
MethodName, but instead passes them by name.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Hello,
> I'm trying to dinamically read a COM objects' methods and parameters
list at
> run time, in order to later place an Invoke() call.

> Using GetIDsOfNames, I can get the method's DISPID, which I can then
use in
> Invoke (and this is working); however, reading documentation for
> GetIDsOfNames lets me understand I should be able to extract the
method's
> parameters list, with a single call to GetIDsOfNames in which I am to
pass
> an array of names (right?).

> I tried the following, but am not able to understand how to extract
info
> about parameters (I just want parameters names, so that I can later
parse
> values into a DISPPARAMS structure):

> DISPID dispidParam;
> OLECHAR FAR* szParam = {L"myMethod\0szFirstParam"};

> hresult = pdisp->GetIDsOfNames( IID_NULL, &szParam, 1,

LOCALE_USER_DEFAULT,
Quote:
> &dispidParam);

> "myMethod" is the method name, while "szFirstParam" is the first (and
only)
> parameter name.
> Not sure this is ok.. I actually tested much with:

> DISPID dispidParam;
> OLECHAR FAR* szParam = L"myMethod";

> hresult = pdisp->GetIDsOfNames( IID_NULL, &szParam, 1,

LOCALE_USER_DEFAULT,

- Show quoted text -

Quote:
> &dispidParam);

> assuming GetIDsOfNames should return info for the method and its
parameters;
> however, dispidParam appears to hold a DISPID for the method only
(later
> call to Invoke is successfull).

> Can anybody point me to the right direction?
> Thank you,
> AL.



Wed, 22 Sep 2004 02:27:39 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. GetActiveObject / GetIDsOfNames returns E_NOIMPL

2. problem with parameter 2 of GetIDsOfNames

3. DISP_E_UNKNOWNNAME from GetIDsOfNames

4. IDispatch::GetIDsOfNames (newbie)

5. DISP_E_UNKNOWNNAME from GetIDsOfNames

6. DISP_E_UNKNOWNNAME from GetIDsOfNames

7. IDispatch::GetIDsOfNames (newbie)

8. Question on GetIDsOfNames

9. Use of GetIDsOfNames for methods

10. ActiveX Collections, Containers, GetIdsOfNames, LPDISPATCH

11. GetIDsOfNames Halts

12. HELP HELP HELP HELP HELP HELP!!!

 

 
Powered by phpBB® Forum Software