locked
Desktop apps on top of Metro RRS feed

  • 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

    jeudi 13 octobre 2011 16:33

Réponses

  • 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

    jeudi 27 octobre 2011 16:10
    Modérateur

Toutes les réponses

  • 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
    jeudi 13 octobre 2011 16:59
  • 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

    jeudi 13 octobre 2011 20:49
    Modérateur
  • Hi Rob,

    Thanks, that is exactly what I need!

    Regards,
    Christian

    jeudi 13 octobre 2011 23:38
  • 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

    vendredi 14 octobre 2011 17:36
  • 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

     

     

     

     

    jeudi 27 octobre 2011 00:03
    Modérateur
  • 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.

     

    jeudi 27 octobre 2011 09:10
  • 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

    jeudi 27 octobre 2011 16:10
    Modérateur
  • 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
    jeudi 2 février 2012 11:04
  • 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?

    lundi 13 février 2012 20:01
  • Any update on this? We are still unable to get our .NET app on top of metro, even with UI access.
    lundi 20 février 2012 22:35
  • 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.

    • Proposé comme réponse Jones Fu lundi 16 avril 2012 14:45
    • Non proposé comme réponse Jones Fu lundi 16 avril 2012 14:45
    mercredi 29 février 2012 22:17
  • 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!!

    lundi 16 avril 2012 14:50
  • 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.

    lundi 16 avril 2012 18:44
    Modérateur