IDispatch::GetIDsOfNames (newbie) 
Author Message
 IDispatch::GetIDsOfNames (newbie)

Hi,

I'm using VC++6.0.

I got a automation object, and I would like to use it. Well obviously. I'm
fairly new to COM. The interface of the object I have, is only accessible
via this IDispatch interface. In fact there is only one function of the
object I need to access. It's called getWelcomeMessageFileID, and it has one
BSTR as input parameter, it doesn't return a HRESULT, but a BSTR. Actually
the declaration (which I got from a .tli file via #import) looks like this:

inline _bstr_t GetUserWelcomeMessage_Dispatch::getWelcomeMessageFileID
 _bstr_t Parameter0 )

Right now I am as far as trying to get de DISPIDs for the member name and
the parameter. For this I use IDispatch::GetIDsOfNames(). Well,
GetUserWelcomeMessage_Dispatch::GetIDsOfNames() to be more precise.

This is how I call the function:

  wchar_t tusaBuffer1[100];
  wchar_t tusaBuffer2[100];
  OLECHAR FAR* Names[2] = {tusaBuffer1,tusaBuffer2};
  wcscpy((wchar_t*)Names[0],_TEXT("getWelcomeMessageFileID"));
  wcscpy((wchar_t*)Names[1],_TEXT("Parameter0"));
  DISPID tlaDispId[2];

  lResult =
lpDispatch->GetIDsOfNames(IID_NULL,Names,2,LOCALE_SYSTEM_DEFAULT,tlaDispId);

And the result is: DISP_E_UNKNOWNNAME.
In fact I receive a DISPID for the member name (0x6e), but the DISPID for
the parameter name contains -1.

What am I doing wrong? Or what am I forgetting?

Thanks,

--
Frederiek

Note: when replying to my return address make sure to remove 'NOSPAM.'.



Mon, 29 Jul 2002 03:00:00 GMT  
 IDispatch::GetIDsOfNames (newbie)

To call a function through IDispatch, you need to do two things. (1)
Call GetIDsOfNames to resolve the function name to an ID. Pass the ID
and any function parameters to Invoke in order to actually call the
function. So basically, you shouldn't be passing the parameter to
GetIDsofNames.

Paul Gunn

Quote:

>Hi,

>I'm using VC++6.0.

>I got a automation object, and I would like to use it. Well obviously. I'm
>fairly new to COM. The interface of the object I have, is only accessible
>via this IDispatch interface. In fact there is only one function of the
>object I need to access. It's called getWelcomeMessageFileID, and it has one
>BSTR as input parameter, it doesn't return a HRESULT, but a BSTR. Actually
>the declaration (which I got from a .tli file via #import) looks like this:

>inline _bstr_t GetUserWelcomeMessage_Dispatch::getWelcomeMessageFileID
> _bstr_t Parameter0 )

>Right now I am as far as trying to get de DISPIDs for the member name and
>the parameter. For this I use IDispatch::GetIDsOfNames(). Well,
>GetUserWelcomeMessage_Dispatch::GetIDsOfNames() to be more precise.

>This is how I call the function:

>  wchar_t tusaBuffer1[100];
>  wchar_t tusaBuffer2[100];
>  OLECHAR FAR* Names[2] = {tusaBuffer1,tusaBuffer2};
>  wcscpy((wchar_t*)Names[0],_TEXT("getWelcomeMessageFileID"));
>  wcscpy((wchar_t*)Names[1],_TEXT("Parameter0"));
>  DISPID tlaDispId[2];

>  lResult =
>lpDispatch->GetIDsOfNames(IID_NULL,Names,2,LOCALE_SYSTEM_DEFAULT,tlaDispId);

>And the result is: DISP_E_UNKNOWNNAME.
>In fact I receive a DISPID for the member name (0x6e), but the DISPID for
>the parameter name contains -1.

>What am I doing wrong? Or what am I forgetting?

>Thanks,

>--
>Frederiek

>Note: when replying to my return address make sure to remove 'NOSPAM.'.



Mon, 29 Jul 2002 03:00:00 GMT  
 IDispatch::GetIDsOfNames (newbie)
To tell you the truth, I haven't worked with named arguments via IDispatch.
However, you can simply ignore them - your Invoke call will be simpler too.
Just ask for the method DISPID and then pass it by position (it is only one
after all) in your Invoke call. It's probably redundant to point out to the
documentation for IDispatch. Also, look up chapter 14 of "Inside OLE".

--
===============================
Alexander Nickolov
Microsoft MVP [VC], MCSD

===============================

Quote:

>Hi,

>I'm using VC++6.0.

>I got a automation object, and I would like to use it. Well obviously. I'm
>fairly new to COM. The interface of the object I have, is only accessible
>via this IDispatch interface. In fact there is only one function of the
>object I need to access. It's called getWelcomeMessageFileID, and it has
one
>BSTR as input parameter, it doesn't return a HRESULT, but a BSTR. Actually
>the declaration (which I got from a .tli file via #import) looks like this:

>inline _bstr_t GetUserWelcomeMessage_Dispatch::getWelcomeMessageFileID
> _bstr_t Parameter0 )

>Right now I am as far as trying to get de DISPIDs for the member name and
>the parameter. For this I use IDispatch::GetIDsOfNames(). Well,
>GetUserWelcomeMessage_Dispatch::GetIDsOfNames() to be more precise.

>This is how I call the function:

>  wchar_t tusaBuffer1[100];
>  wchar_t tusaBuffer2[100];
>  OLECHAR FAR* Names[2] = {tusaBuffer1,tusaBuffer2};
>  wcscpy((wchar_t*)Names[0],_TEXT("getWelcomeMessageFileID"));
>  wcscpy((wchar_t*)Names[1],_TEXT("Parameter0"));
>  DISPID tlaDispId[2];

>  lResult =
>lpDispatch->GetIDsOfNames(IID_NULL,Names,2,LOCALE_SYSTEM_DEFAULT,tlaDispId)
;

>And the result is: DISP_E_UNKNOWNNAME.
>In fact I receive a DISPID for the member name (0x6e), but the DISPID for
>the parameter name contains -1.

>What am I doing wrong? Or what am I forgetting?

>Thanks,

>--
>Frederiek

>Note: when replying to my return address make sure to remove 'NOSPAM.'.



Mon, 29 Jul 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. IDispatch::GetIDsOfNames (newbie)

2. newbie::IDispatch reference count?

3. GetIDsOfNames help

4. GetActiveObject / GetIDsOfNames returns E_NOIMPL

5. problem with parameter 2 of GetIDsOfNames

6. DISP_E_UNKNOWNNAME from GetIDsOfNames

7. DISP_E_UNKNOWNNAME from GetIDsOfNames

8. DISP_E_UNKNOWNNAME from GetIDsOfNames

9. Question on GetIDsOfNames

10. Use of GetIDsOfNames for methods

11. ActiveX Collections, Containers, GetIdsOfNames, LPDISPATCH

12. GetIDsOfNames Halts

 

 
Powered by phpBB® Forum Software