[C++/WinRT Windows Console Application] How to use DispGetIDsOfNames to implement IDispatch::GetIDsOfNames method?

Dung Huynh 141 Reputation points
2023-06-13T13:44:22.03+00:00

Hi,

I create a C++/WinRT Windows Console Application project and try to implement the IDispatch interface.

This is the class.h

User's image

And following is class.cpp. In the method GetIDsOfNames, I am trying to use the method DispGetIDsOfNames from oleauto.h header.

User's image

However, it gets the complier error that *Error LNK2019 unresolved external symbol __imp_DispGetIDsOfNames referenced in function "public: virtual long __cdecl int __cdecl main(void)'::2'::MyCoclass::GetIDsOfNames(struct _GUID const &,wchar_t * *,unsigned int,unsigned long,long )" (?GetIDsOfNames@MyCoclass@?1??main@@YAHXZ@UEAAJAEBU_GUID@@PEAPEA_WIKPEAJ@Z)User's image

Could you help me with fixing this compiler error? how to implement the GetIDsOfNames method?Could you help me with fixing this compiler error? how to implement the GetIDsOfNames method?Thank you and kind regards,

Could you help me with fixing this compiler error? how to implement the GetIDsOfNames method?Could you help me with fixing this compiler error? how to implement the GetIDsOfNames method?Thank you and kind regards,

Could you help me with fixing this compiler error? how to implement the GetIDsOfNames method?Could you help me with fixing this compiler error? how to implement the GetIDsOfNames method?Thank you and kind regards,

Dung Huynh.

Developer technologies | C++
{count} votes

Accepted answer
  1. Viorel 122.6K Reputation points
    2023-06-13T14:00:02.2+00:00

    Does it work if the next line is added to any .cpp file?

    #pragma comment(lib, "OleAut32")
    
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.