Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

HMD SpatialLocator in Win32 app requires UAC using Windows 10 April 2018 Update 1803


I have successfully gotten HMD pose from Windows.Perception.Spatial.SpatialLocator class in a Win32 app. I did this by compiling the project with C++/Cx enabled and pointing my VS project property pages to the the right #using folders:

C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17134.0;
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\vcpackages

When I build, I can sample HMD pose using the following code on 1703 (2018 Fall Creators Update Windows 10):


Windows::Globalization::Calendar^ c = ref new Windows::Globalization::Calendar;
SpatialLocator ^m_locator = SpatialLocator::GetDefault();
SpatialStationaryFrameOfReference^ m_referenceFrame = m_locator->CreateStationaryFrameOfReferenceAtCurrentLocation();

while (true)
    if (m_locator->Locatability == SpatialLocatability::PositionalTrackingActive)
        SpatialLocation^ head_pose = m_locator->TryLocateAtTimestamp(Windows::Perception::PerceptionTimestampHelper::FromHistoricalTargetTime(c->GetDateTime()), m_referenceFrame->CoordinateSystem);

        if (head_pose != nullptr)
            std::cout << "ROT: {" << head_pose->Orientation.w << ", " << head_pose->Orientation.x << ", " << head_pose->Orientation.y << ", " << head_pose->Orientation.z << "}" << std::endl;
            std::cout << "POS: {" << head_pose->Position.x << ", " << head_pose->Position.y << ", " << head_pose->Position.z << "}" << std::endl;



On version 1803, this code does not work as expected. I can see that the Locatability property changes, but every time it changes to "PositionActive" for example, it immediately changes Locatability back to "Unavailable" and TryLocateAtTimestamp() always returns null.

After trying a few things, I found out that if I launch my .exe using "Run as Administrator..." in the explorer, the code behaves as expected and I am able to get the pose of the HMD.

Is this a bug? Is there a way to grant permission to use the HMD in a win32 .exe without having to run the .exe as administrator?


Sign In or Register to comment.