Hello,
Welcome to Microsoft Q&A.
Referring to the document, you could configure your pure c++ console app with the Microsoft.Windows.CppWinRT NuGet package to enable the c++ console app use C++/WinRT APIs, so that you can get the parameters by using ApplicationData
API.
Please check the following steps for your c++ console project:
- Open the NuGet Package Manager(option Tools > NuGet Package Manager > Manage NuGet Package for Solution…).
- Input
cppwinrt
in Browse page, find Microsoft.Windows.CppWinRT and install it for your c++ console project. - Open the Properties page for your c++ console project, in Configuration Properties > General page, set the option C++ Language Standard as ISO C++ 17 Standard(/std:c++ 17).
- In your c++ console project, add the necessary header file and code to test the
ApplicationData
API, for example: #include <iostream>
#include <winrt/Windows.Storage.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h> int main()
{
std::cout << "Hello World!\n";
}winrt::Windows::Storage::ApplicationDataContainer localSettings= winrt::Windows::Storage::ApplicationData::Current().LocalSettings(); auto values = localSettings.Values(); //values.Insert(L"exampleSetting", winrt::Windows::Foundation::PropertyValue::CreateString(L"Hello Windows")); winrt::hstring val = winrt::unbox_value<winrt::hstring>(values.Lookup(L"parameters")); std::wcout << val.c_str() << std::endl; system("PAUSE");
For more information about C++/WinRT, you could refer to the document.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.