Hello,
Welcome to Microsoft Q&A!
We usually use com_array<hstring> to pass parameters to and from Windows Runtime APIs instead of hstring[] when a String[] declared in an idl file. In addition, you do not need to manually write the prototype of the aaa method. The midl.exe > cppwinrt.exe tool chain will implement templates including the definition and declaration of aaa method in Generated Files(\Project-Name\RuntimeComponent\Generated Files\sources). For more information, you can refer to this document. You could also check the following steps:
First: Declare the String[] aaa(String[] v); in Class.idl of the component.
namespace RuntimeComponent
{
[default_interface]
runtimeclass Class
{
Class();
Int32 MyProperty;
String[] aaa(String[] v);
}
}
Second: Save and build the project.
Third: Open the folder \Project-Name\RuntimeComponent\Generated Files\sources in your project folder, open the Class.h and Class.cpp files and copy the definition and declaration code of aaa into the component.
Class.h
namespace winrt::RuntimeComponent::implementation
{
struct Class : ClassT<Class>
{
……
com_array<hstring> aaa(array_view<hstring const> v);
};
}
Class.cpp
namespace winrt::RuntimeComponent::implementation
{
……
com_array<hstring> Class::aaa(array_view<hstring const> v)
{
throw hresult_not_implemented();
}
}
For more information about winrt::com_array struct template, you can refer to the document.