AppxManifest.xml 中 C++/WinRT 控制台 UWP 应用的入口点是什么?
What's the EntryPoint in AppxManifest.xml for C++/WinRT console UWP apps?
This 博客 post 关于命令行 UWP 应用说 "The Executable is the name of your UWA app EXE, and the EntryPoint is the fully qualified name of your App class."
这对 C# 应用程序有意义,但是 C++/WinRT console UWP app template 呢?我们唯一的代码是这样的:
int main()
{
// You can get parsed command-line arguments from the CRT globals.
wprintf(L"Parsed command-line arguments:\n");
for (int i = 0; i < __argc; i++)
{
wprintf(L"__argv[%d] = %S\n", i, __argv[i]);
}
wprintf(L"Press Enter to continue:");
getchar();
}
主要内容是:
...
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="UWPConsoleApp.App"
...
我将项目命名为 UWPConsoleApp,这就是 VS 设置为入口点的地方,但是这个 class 在哪里?编译器是否生成它,它是由宏控制的一些晦涩的 vcruntime init 代码还是完全不同的东西?
那些manifest值在这里基本不用,不用担心。 C++/CX 与 C++/WinRT 的 Package.appxmanifest
没有区别。
启动差异在于您的代码入口点:
// C++/CX
[Platform::MTAThread]
int __cdecl main(Platform::Array<Platform::String^>^ /*argv*/)
{
auto viewProviderFactory = ref new ViewProviderFactory();
CoreApplication::Run(viewProviderFactory);
return 0;
}
对比
// C++/WinRT
int WINAPI wWinMain(
_In_ HINSTANCE /*hInstance*/,
_In_ HINSTANCE /*hPrevInstance*/,
_In_ LPWSTR /*lpCmdLine*/,
_In_ int /*nCmdShow*/
)
{
ViewProviderFactory viewProviderFactory;
CoreApplication::Run(viewProviderFactory);
return 0;
}
This 博客 post 关于命令行 UWP 应用说 "The Executable is the name of your UWA app EXE, and the EntryPoint is the fully qualified name of your App class."
这对 C# 应用程序有意义,但是 C++/WinRT console UWP app template 呢?我们唯一的代码是这样的:
int main()
{
// You can get parsed command-line arguments from the CRT globals.
wprintf(L"Parsed command-line arguments:\n");
for (int i = 0; i < __argc; i++)
{
wprintf(L"__argv[%d] = %S\n", i, __argv[i]);
}
wprintf(L"Press Enter to continue:");
getchar();
}
主要内容是:
...
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="UWPConsoleApp.App"
...
我将项目命名为 UWPConsoleApp,这就是 VS 设置为入口点的地方,但是这个 class 在哪里?编译器是否生成它,它是由宏控制的一些晦涩的 vcruntime init 代码还是完全不同的东西?
那些manifest值在这里基本不用,不用担心。 C++/CX 与 C++/WinRT 的 Package.appxmanifest
没有区别。
启动差异在于您的代码入口点:
// C++/CX
[Platform::MTAThread]
int __cdecl main(Platform::Array<Platform::String^>^ /*argv*/)
{
auto viewProviderFactory = ref new ViewProviderFactory();
CoreApplication::Run(viewProviderFactory);
return 0;
}
对比
// C++/WinRT
int WINAPI wWinMain(
_In_ HINSTANCE /*hInstance*/,
_In_ HINSTANCE /*hPrevInstance*/,
_In_ LPWSTR /*lpCmdLine*/,
_In_ int /*nCmdShow*/
)
{
ViewProviderFactory viewProviderFactory;
CoreApplication::Run(viewProviderFactory);
return 0;
}