最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - WPF Window with WS_EX_TOOLWINDOW Appears in Alt+Tab After Explorer.exe Restart When Launched with UI Access Token - Stack O

programmeradmin6浏览0评论

I'm experiencing an unexpected behavior with a WPF window that's created with WS_EX_TOOLWINDOW style when the application is launched with UI Access token privileges.

Issue Description: A window with WS_EX_TOOLWINDOW style unexpectedly appears in Alt+Tab after explorer.exe is restarted, but only when the application is launched with UI Access token. This doesn't occur when running the application directly.

Steps to Reproduce:

  1. Start WPF application through a service using SetTokenInformation with TokenUIAccess
  2. Create transparent, topmost window with WS_EX_TOOLWINDOW style
  3. Kill explorer.exe from Task Manager (Details tab)
  4. Start explorer.exe using "Run new task"
  5. Press Alt+Tab - window appears despite WS_EX_TOOLWINDOW style

Window Styles Verification: I verified using Spy++ that the styles remain unchanged after explorer.exe restart: .png

The image shows Window Styles (0x680000) and Extended Styles (0x80A8) remain consistent before and after reproducing the issue, confirming WS_EX_TOOLWINDOW is still applied.

Code:

// Setting UI Access token
uint dwUIAccess = 1;
SetTokenInformation(hUserToken, TOKEN_INFORMATION_CLASS.TokenUIAccess, ref dwUIAccess, sizeof(uint));

// Window styles
var hwnd = new WindowInteropHelper(this).Handle;
var extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT);

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论