Most popular even for modern applications

I have a recording program that remains TopMost all the time, unless I open the Modern app (Windows 8) or Start Screen .

Perhaps the desktop application will remain on top of modern applications, for example, using the Magnifying Glass tool:

Topmost

Now the problem is that using the TopMost option and / or calling the API in the WPF window will not work with modern applications.

What am I trying:

 static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2); static readonly IntPtr HWND_TOP = new IntPtr(0); static readonly IntPtr HWND_BOTTOM = new IntPtr(1); const UInt32 SWP_NOSIZE = 0x0001; const UInt32 SWP_NOMOVE = 0x0002; const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE; [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); //OnLoaded event handler: var source = PresentationSource.FromVisual(this) as HwndSource; SetWindowPos(source.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS); 
+7
c # wpf topmost
source share
1 answer

Only applications marked as access-related can do this. To achieve this, follow these recommendations (taken from the comments section of this article ):

  • The application must require uiAccess (app.manifest)
  • The application must state the "highest" position of the window (either in the Win32 / SetWindowPos properties, or in WinForms / WPF "Topmost", programmatically or otherwise)
  • Without making changes to the Group Policy setting, it must be installed in a specific trusted location [C: \ Windows, C: \ Program Files, C: \ Program Files (x86)]. but. Note. If you want to be able to run its arbitrary location, you must disable the security setting: "User Account Control: just pick up the UIAccess applications that are installed in safe places.". Note2: This is the same as setting HKLM \ Software \ Microsoft \ Windows \ CurrentVersion \ Policies \ System \ ValidateAdminCodeSignatures to 0
  • The specified application cannot be started in the debugger
  • If this is a .NET application a. The manifest must be built into post-build b. The application should have a โ€œdelayed signingโ€, (this means that it cannot be launched from the built-in debugger, although you can build and attach - this is what Microsoft does)
  • The application must be signed with a trusted certificate.
  • The specified trusted certificate must be installed in the trusted root certification authority (this is important! It is not just installed) For more information see: http://msdn.microsoft.com/en-us/library/ms726294

... Not quite a trivial task!

+2
source share

All Articles