[!NOTE] This feature is only available to PCs running the latest Windows Insider flights (RS5), build 17704 and newer.
The Windows Mixed Reality home is the starting point where users land before launching applications. By default, you need to launch immersive Win32 VR apps and games from outside the headset and won’t appear in the “All apps” list on the Windows Mixed Reality Start menu. If you follow the instructions in this article to implement a 3D app launcher, your immersive Win32 VR experience can be launched from within the Windows Mixed Reality Start menu and home environment.
This is only true for immersive Win32 VR experiences distributed outside of Steam. For VR experiences distributed through Steam, we’ve updated the Windows Mixed Reality for SteamVR Beta along with the latest Windows Insider RS5 flights so that SteamVR titles show up in the Windows Mixed Reality Start menu in the “All apps” list automatically using a default launcher. In other words, the method described in this article is unnecessary for SteamVR titles and will be overridden by the Windows Mixed Reality for SteamVR Beta functionality.
There are three steps to creating a 3D app launcher:
3D assets to be used as launchers for your application should be authored using the Windows Mixed Reality authoring guidelines to ensure compatibility. Assets that fail to meet this authoring specification won’t be rendered in the Windows Mixed Reality home.
Win32 applications will appear in the “All apps” list on the Windows Mixed Reality Start menu if you create a 3D app launcher for them. To do that, create a Visual Elements Manifest XML file referencing the 3D App Launcher by following these steps:
<Application xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance">
<VisualElements
ShowNameOnSquare150x150Logo="on"
Square150x150Logo="YOUR_APP_LOGO_150X150.png"
Square70x70Logo=" YOUR_APP_LOGO_70X70.png"
ForegroundText="light"
BackgroundColor="#000000">
<MixedRealityModel Path="YOUR_3D_APP_LAUNCHER_ASSET.glb">
<SpatialBoundingBox Center="0,0,0" Extents="Auto" />
</MixedRealityModel>
</VisualElements>
</Application>
The sample code below shows how you can create a shortcut in C++, including overriding the path to the Visual Elements Manifest XML file. Note the override is only required in cases where your shortcut doesn’t point directly to the EXE associated with the manifest (for example, your shortcut uses a custom protocol handler like “myapp://”).
#include <windows.h>
#include <propkey.h>
#include <shlobj_core.h>
#include <shlwapi.h>
#include <propvarutil.h>
#include <wrl.h>
#include <memory>
using namespace Microsoft::WRL;
#define RETURN_IF_FAILED(x) do { HRESULT hr = x; if (FAILED(hr)) { return hr; } } while(0)
#define RETURN_IF_WIN32_BOOL_FALSE(x) do { DWORD res = x; if (res == 0) { return HRESULT_FROM_WIN32(GetLastError()); } } while(0)
int wmain()
{
RETURN_IF_FAILED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED));
ComPtr<IShellLink> shellLink;
RETURN_IF_FAILED(CoCreateInstance(__uuidof(ShellLink), nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink)));
RETURN_IF_FAILED(shellLink->SetPath(L"MyLauncher://launch/app-identifier"));
// It is also possible to use an icon file in another location. For example, "C:\Program Files (x86)\MyLauncher\assets\app-identifier.ico".
RETURN_IF_FAILED(shellLink->SetIconLocation(L"C:\\Program Files (x86)\\MyLauncher\\apps\\app-identifier\\game.exe", 0 /*iIcon*/));
ComPtr<IPropertyStore> propStore;
RETURN_IF_FAILED(shellLink.As(&propStore));
{
// Optional: If the application has an explict Application User Model ID, then you should usually specify it in the shortcut.
PROPVARIANT propVar;
RETURN_IF_FAILED(InitPropVariantFromString(L"ExplicitAppUserModelID", &propVar));
RETURN_IF_FAILED(propStore->SetValue(PKEY_AppUserModel_ID, propVar));
PropVariantClear(&propVar);
}
{
// A hint path to the manifest is only necessary if the target path of the shortcut is not a file path to the executable.
// By convention the manifest is named <executable name>.VisualElementsManifest.xml and is in the same folder as the executable
// (and resources.pri if applicable). Assets referenced by the manifest are relative to the folder containing the manifest.
//
// PropKey.h
//
// Name: System.AppUserModel.VisualElementsManifestHintPath -- PKEY_AppUserModel_VisualElementsManifestHintPath
// Type: String -- VT_LPWSTR (For variants: VT_BSTR)
// FormatID: {9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}, 31
//
// Suggests where to look for the VisualElementsManifest for a Win32 app
//
// DEFINE_PROPERTYKEY(PKEY_AppUserModel_VisualElementsManifestHintPath, 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 31);
// #define INIT_PKEY_AppUserModel_VisualElementsManifestHintPath { { 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3 }, 31 }
PROPVARIANT propVar;
RETURN_IF_FAILED(InitPropVariantFromString(L"C:\\Program Files (x86)\\MyLauncher\\apps\\app-identifier\\game.visualelementsmanifest.xml", &propVar));
RETURN_IF_FAILED(propStore->SetValue(PKEY_AppUserModel_VisualElementsManifestHintPath, propVar));
PropVariantClear(&propVar);
}
constexpr PCWSTR shortcutPath = L"%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\game.lnk";
const DWORD requiredBufferLength = ExpandEnvironmentStrings(shortcutPath, nullptr, 0);
RETURN_IF_WIN32_BOOL_FALSE(requiredBufferLength);
const auto expandedShortcutPath = std::make_unique<wchar_t[]>(requiredBufferLength);
RETURN_IF_WIN32_BOOL_FALSE(ExpandEnvironmentStrings(shortcutPath, expandedShortcutPath.get(), requiredBufferLength));
ComPtr<IPersistFile> persistFile;
RETURN_IF_FAILED(shellLink.As(&persistFile));
RETURN_IF_FAILED(persistFile->Save(expandedShortcutPath.get(), FALSE));
return 0;
}
[{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}]
Prop31=C:\Program Files (x86)\MyLauncher\apps\app-identifier\game.visualelementsmanifest.xml
Prop5=ExplicitAppUserModelID
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,0
[InternetShortcut]
IDList=
URL=MyLauncher://launch/app-identifier
IconFile=C:\Program Files (x86)\MyLauncher\apps\app-identifier\game.exe
IconIndex=0