Reputation: 397
I have not been able to find any documentation on how to process the command line arguments of a C++/WinRT, XAML app.
In Visual Studio 15.9.6 the application properties do provide a way to enter command line arguments during the development effort, but no way to process them.
For a Blank App (C++/WinRT) template, the App.cpp file has the following:
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
App::App()
{
...
}
wherein main() and WinMain() are mentioned.
I would expect to have some number of main() or WinMain() read arguments which would then be processed by the application.
Upvotes: 2
Views: 1536
Reputation: 51345
There are several ways to get the command line arguments in a UWP XAML application. The natural way to get the command line is to override the Application::OnLaunched member, that gets passed a LaunchActivatedEventArgs argument. Its Arguments property holds the command line.
Alternatively, you can query the OS: GetCommandLineW returns the command line from anywhere inside the application. (Note, that CommandLineToArgvW to parse the command line into individual arguments is not available in a UWP application.)
If you do need the command line decomposed into individual arguments, you'll have to go with a Microsoft specific extension to its C Runtime implementation: __argc
and __wargv
provide the decomposed command line arguments the same way you would get them through a standard main
entry point.
Upvotes: 4