Your first console application targeting Windows Athens, with step-to-step instructions.
We’ll create a simple headless console application that can be used to query the memory usage on your MinnowBoard Max (or MBM for short).
You can find this sample in the Samples\MemoryStatus folder.
Create a new project (File | New Project…). In the ‘New Project’ dialog, navigate to ‘Windows Athens Apps’ as shown below (in the left pane in the dialog: Templates | Visual C++ | Store Apps | Windows Athens Apps).
Select the template ‘Blank Athens Console Application’
Remember to give a good name to your first app! In this example, we called the project ‘MemoryStatus’.

Let’s add some content to the console application. From Solution Explorer, select the ‘ConsoleApplication.cpp’ file.

To add some functionality to our console, add the following memory status query and display code:
#include "pch.h"
#include <windows.h>
#include <chrono>
#include <thread>
using namespace std;
// Use to convert bytes to KB
#define DIV 1024
// Specify the width of the field in which to print the numbers.
#define MESSAGE_WIDTH 30
#define NUMERIC_WIDTH 10
void printMessage(LPCSTR msg, bool addColon)
{
cout.width(MESSAGE_WIDTH);
cout << msg ;
if (addColon)
{
cout << " : ";
}
}
void printMessageLine(LPCSTR msg)
{
printMessage(msg, false);
cout << endl;
}
void printMessageLine(LPCSTR msg, DWORD value)
{
printMessage(msg, true);
cout.width(NUMERIC_WIDTH);
cout << right << value << endl;
}
void printMessageLine(LPCSTR msg, DWORDLONG value)
{
printMessage(msg, true);
cout.width(NUMERIC_WIDTH);
cout << right << value << endl;
}
int main(int argc, char **argv)
{
printMessageLine("Starting to monitor memory consumption!");
for (;;)
{
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
BOOL success = GlobalMemoryStatusEx(&statex);
if (!success)
{
DWORD error = GetLastError();
printMessageLine("*************************************************");
printMessageLine("Error getting memory information", error);
printMessageLine("*************************************************");
}
else
{
DWORD load = statex.dwMemoryLoad;
DWORDLONG physKb = statex.ullTotalPhys / DIV;
DWORDLONG freePhysKb = statex.ullAvailPhys / DIV;
DWORDLONG pageKb = statex.ullTotalPageFile / DIV;
DWORDLONG freePageKb = statex.ullAvailPageFile / DIV;
DWORDLONG virtualKb = statex.ullTotalVirtual / DIV;
DWORDLONG freeVirtualKb = statex.ullAvailVirtual / DIV;
DWORDLONG freeExtKb = statex.ullAvailExtendedVirtual / DIV;
printMessageLine("*************************************************");
printMessageLine("Percent of memory in use", load);
printMessageLine("KB of physical memory", physKb);
printMessageLine("KB of free physical memory", freePhysKb);
printMessageLine("KB of paging file", pageKb);
printMessageLine("KB of free paging file", freePageKb);
printMessageLine("KB of virtual memory", virtualKb);
printMessageLine("KB of free virtual memory", freeVirtualKb);
printMessageLine("KB of free extended memory", freeExtKb);
printMessageLine("*************************************************");
}
this_thread::sleep_for(chrono::milliseconds(100));
}
printMessageLine("No longer monitoring memory consumption!");
}Make sure the app builds correctly invoking the Build | Build Solution menu command.
This application will run in either headed or headless mode, but to view the output simply, lets look at it in the headless mode. To do this, telnet to your device and log in using the local system account (no username and no password). Run this command and reboot to configure your device to be headless:
For future reference, to return your device to headed mode, you can run this command:
It is easy to deploy this console application to our Athens device. When you set up your environment, you chose a unique name for your Athens device. We’ll use that name in the ‘Remote Machine Debugging’ settings in VS.
In Visual Studio, you can configure your target by editing your project’s properties:

Note: You can use the IP address instead of the Athens device name.
The project configuration needs to be modified to enable deployment. To do this, open the Configuration Manager by selecting the Configuration manger from the Solution Configuration drop-down menu on the toolbar.

From the Configuration Manager, ensure that the Deploy checkbox is selected for your project configuration

Now we’re ready to deploy to the remote Athens device. Simply press F5 (or select Debug | Start Debugging) to start debugging our app. If you've selected headless mode, you should see output on the screen like this (if you have selected headed mode, the DefaultApp will remain on screen while the console application runs):

You can set breakpoints, see variable values, etc. To stop the app, press on the ‘Stop Debugging’ button (or select Debug | Stop Debugging).
Congratulations! You just deployed your first console application to a device running Windows Athens!
As always, for questions and feedback, contact us.