Skip to content

Instantly share code, notes, and snippets.

@domenic
Created November 6, 2012 22:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domenic/4028057 to your computer and use it in GitHub Desktop.
Save domenic/4028057 to your computer and use it in GitHub Desktop.
Programmatically running a Windows 8 Metro app
#include <SDKDDKVer.h>
#include <ShObjIdl.h>
#include <tchar.h>
int wmain(int argc, wchar_t* argv[])
{
const wchar_t* appId = L"WinningJS-test-runner_aw9cjjms6ptaw!App";
CoInitialize(nullptr);
IApplicationActivationManager* aam = nullptr;
HRESULT hr = CoCreateInstance(CLSID_ApplicationActivationManager, nullptr, CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&aam));
if (FAILED(hr)) {
wprintf(L"Error creating ApplicationActivationManager");
return 1;
}
DWORD pid = 0;
hr = aam->ActivateApplication(appId, nullptr, AO_NONE, &pid);
if (FAILED(hr)) {
wprintf(L"Error calling ActivateApplication");
return 1;
}
aam->Release();
CoUninitialize();
return 0;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>runner</title>
<!-- WinJS references -->
<link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
<script src="//Microsoft.WinJS.1.0/js/base.js"></script>
<script src="//Microsoft.WinJS.1.0/js/ui.js"></script>
<script>
WinJS.Application.start();
// Somehow run the tests here?
setTimeout(function () {
window.close();
}, 2000);
</script>
</head>
<body></body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment