locked
Desktop apps on top of Metro

    Question

  • Hi,

    I was wondering if there was documentation about how to make a desktop app "always on top" (this is easy) but also always on top of Metro (like Inspect and Task Manager do).

    This is useful for tools that have to be written for the desktop (because of full access to the Win32 API) but that can be relevant in Metro mode.

    Thanks,
    Christian

    Thursday, October 13, 2011 4:33 PM

Answers

  • UIAccess apps run with special privileges and must be trusted by the system.  Because of that they must run from a location which normal users cannot write to.  See http://msdn.microsoft.com/en-us/library/ms742884.aspx for more detail.

    Again, these features should be used with care and restricted to accessibility applications and very targeted test tools.  Any application using UIAccess should go through a vigorous security review.  UIAccess is not appropriate for general purpose applications.

    --Rob

    Thursday, October 27, 2011 4:10 PM
    Owner

All replies

  • Hello Christian Gavin,

    This thread was created in the Windows Developer Preview: General OS forum; the Microsoft Moderation team has moved this thread to the
    Tools for Metro Style Apps forum.


    Marilyn
    Thursday, October 13, 2011 4:59 PM
  • Hi Christian,

    The application needs to be flagged with accessibility privileges with UIAccess.  See: http://msdn.microsoft.com/en-us/library/ms742884.aspx .

    This should be reserved for accessibility applications and very targeted test tools.  It should not be used for general purpose applications.

    --Rob

    Thursday, October 13, 2011 8:49 PM
    Owner
  • Hi Rob,

    Thanks, that is exactly what I need!

    Regards,
    Christian

    Thursday, October 13, 2011 11:38 PM
  • Hi Rob,

    I changed the manifest to have UIAccess="true" and require administrator, created a private test certificate, signed the application with that certificate, put it in a location under Program Files, and ran it, but it is still not the topmost application when running Metro.

    The dialog box has the "TopMost" style.

    Is there anything else I missed to make my application appear on top of Metro (like Task Manager does)?

    Thanks,
    Christian

    Friday, October 14, 2011 5:36 PM
  • Hi Christian,

    There isn't anything else that needs to be done (my test project was just the standard Win32 Project wizard app plus WS_EX_TOPMOST).  I suspect that the app wasn't manifested and signed properly.  The cert needs to tie back to a trusted root, so you would need to make sure your test cert was trusted; however, if it weren't there would be an error that "A referral was returned from the server".  If you didn't see that, then the problem was more likely in the manifest.  Here's how I created my test project:

    1. Create new Win32 Project
    2. Finish the wizard with no changes
    3. Change the CreateWindow call to CreateWindowEx and set WS_EX_TOPMOST
    4. Go to Project.Properties... Linker.Manifest File
    5. Change UAC Bypass UI Protection to: Yes (/uiAccess='true')
    6. Build
    7. Use signtool to sign the test app
    8. Copy the test app into Program Files
    9. Run test app
    10. Bring up the Start screen -> test app is on top

     

     

     

     

    Thursday, October 27, 2011 12:03 AM
    Owner
  • Very helpful. thanks.

    I verified this works. Just curious why need to copy the exe file to program files folder. Withouth this copy work, the app runs but can not on top of metro style apps.

     

    Thursday, October 27, 2011 9:10 AM
  • UIAccess apps run with special privileges and must be trusted by the system.  Because of that they must run from a location which normal users cannot write to.  See http://msdn.microsoft.com/en-us/library/ms742884.aspx for more detail.

    Again, these features should be used with care and restricted to accessibility applications and very targeted test tools.  Any application using UIAccess should go through a vigorous security review.  UIAccess is not appropriate for general purpose applications.

    --Rob

    Thursday, October 27, 2011 4:10 PM
    Owner
  • Hi Rob, I'm implement this function in VS2011 with C#. My step is: 1. create a WinForm project 2. pinvoke CreateWindowEx with WS_EX_TOPMOST style 3. add manifest file for this project 4. change level='highestAvailable' uiAccess='ture' 5. sign the assembly in properties window 6. compile and copy to program file directory but cannot run .exe, could you send me your source code and tell me how to operate in .NET ? Thanks in advance Best regards Chenxu
    Thursday, February 02, 2012 11:04 AM
  • We have a .NET app that has a window that needs to be able to go on top of the Metro UI. The window is defined in XAML with the TopMost property set to true. The assembly has an app.manifest embedded requesting uiaccess, and is signed properly. I launch the app from a folder under C:\Program Files (x86)\. Inspecting the window with Spy++ shows that it does indeed have the WS_EX_TOPMOST attribute. Inspecting the process security with process explorer shows that it was granted uiaccess appropriately. 

    However, when the window is shown, it causes the metro UI to go away. If I bring the Metro UI back up by pressing the Win key, the window does not show on top of the metro UI. Any ideas as to why this does not work?

    Monday, February 13, 2012 8:01 PM
  • Any update on this? We are still unable to get our .NET app on top of metro, even with UI access.
    Monday, February 20, 2012 10:35 PM
  • How's how I got it working. Note that you'll lose debug capability in the IDE.

    1. The application must demand uiAccess (app.manifest)
    2. The application must assert “topmost” window positioning (either in Win32/SetWindowPos or WinForms/WPF’s “Topmost” property, programmatically or otherwise)
    3. Without making changes to the group policy setting, it must be installed to some trusted location [C:\Windows, C:\Program Files, C:\Program Files (x86)].
      1. Note: If you want to be able to run it out of an arbitrary location, you must disable the security setting: “User Account Control: Only elevate UIAccess applications that are installed in secure locations”.
      2. Note2: This is the same as setting HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\ValidateAdminCodeSignatures to 0
    4. Said application cannot be ran in the debugger
    5. If it’s a .NET application
      1. The manifest must be embedded in a post-build step
      2. The application must have “delayed signing” (meaning it cannot be ran from the built-in debugger, although you can build and attach – this is what Microsoft does)
    6. The application must be signed with a trusted certificate.
    7. Said trusted certificate must be installed to the Trusted Root Certificate Authority (this is important! It must not just simply installed)

    Hope this helps.

    • Proposed as answer by Jones Fu Monday, April 16, 2012 2:45 PM
    • Unproposed as answer by Jones Fu Monday, April 16, 2012 2:45 PM
    Wednesday, February 29, 2012 10:17 PM
  • Hi Rob

        I follow you and success to write a desktop app(WPF) on top of metro. But I met a problem: if I set "this.ShowInTaskbar = false", my desktop window can not show on top of metro. Why and How to solve this issue? Please help!!

    Monday, April 16, 2012 2:50 PM
  • That probably has something to do with how the ShowInTaskbar property is implemented. My guess is that it sets the owner to a hidden window, but you should ask this on the WPF forum (I moved your duplicate post there).

    I'm locking this thread since it is off-topic and keeps getting further off-topic posts added to it.

    Please post questions about developing desktop apps in the Windows Desktop Developer Forums. Please post questions specific to the various .Net frameworks in those dedicated forums.

    Monday, April 16, 2012 6:44 PM
    Owner