How to export data, functions, classes from C++/WinRT library

202 Views Asked by At

Usually we are using dllexport/dllimport method for c++ libraries. Then a test application can use the dll implicitly/explicitly for accessing the dll functions. Also we can make use of .winmd files in the c++/winRT to access the classes, functions using a test application.

Then what is the difference between these two concepts? Which one is better for a c++/WinRT library(dll).

1

There are 1 best solutions below

0
On

dllexport and dllimport allow symbols to be exported from a PE image, and imported using load-time dynamic linking. Client code that wants to consume symbols is required to know the name(s) of those symbols.

WinMD files, on the other hand, provide metadata for types, including their layout in memory, visibility, or names. WinMD metadata isn't competing with module-level export/import mechanics, it's complementary.

The question, which one is better, thus doesn't make sense. For Windows Runtime Components you would usually provide WinMD files that describe the types, but the PE binary still needs to export certain symbols, like the activation factory so that RoGetActivationFactory can do its work.