Skip to content

Commit 2e26492

Browse files
committed
Explain how to use static libraries.
1 parent fb3989c commit 2e26492

File tree

1 file changed

+23
-2
lines changed
  • vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary

1 file changed

+23
-2
lines changed

vsix/ProjectTemplates/VC/Windows Universal/StaticLibrary/readme.txt

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,29 @@
55
This project demonstrates how to get started authoring Windows Runtime
66
classes directly with standard C++, using the C++/WinRT SDK component
77
to generate implementation headers from interface (IDL) files. The
8-
generated Windows Runtime component binary and WinMD files should then
9-
be bundled with the Universal Windows Platform (UWP) app consuming them.
8+
generated static library should be consumed by a single Runtime Component
9+
or App project and the and types will automatically be added to that
10+
binary.
11+
To be able to instantiate types from the static library you need to
12+
update the activation factory in the consuming binary to call the
13+
activation factory exposed by this static library using code similar to:
14+
15+
void* __stdcall $projectname$_get_activation_factory(
16+
std::wstring_view const& name);
17+
18+
void* __stdcall winrt_get_activation_factory(
19+
std::wstring_view const& name)
20+
{
21+
void* factory = $projectname$_get_activation_factory(name);
22+
if (factory)
23+
{
24+
return factory;
25+
}
26+
27+
/* call other activation factories */
28+
29+
return nullptr;
30+
}
1031

1132
Steps:
1233
1. Create an interface (IDL) file to define your Windows Runtime class,

0 commit comments

Comments
 (0)