Repository navigation
fix: 启动 wmic 等子进程时隐藏控制台窗口,避免 GUI 应用闪窗 - #175
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
在 WinForms/WPF 等没有控制台的 GUI 宿主中使用 Stardust 时,应用启动后会出现一次控制台窗口闪现。
Windows 下的触发链:
StarClient.GetNodeInfo()→FillOnWindows()→GetGpuInfo()。当 DXGI 枚举不到显卡时(RDP 会话、虚拟机、Microsoft Basic Display Adapter 等常见场景),会回退到GetGpuListByWmi()→ExecuteWmicCached()→Execute("wmic", ...)。Execute创建的ProcessStartInfo只设置了UseShellExecute = false,没有设置CreateNoWindow = true,因此wmic.exe会新建一个可见的控制台窗口。心跳FillPingOnWindows()在 PDH 不可用时同样会回退到 wmic,存在相同问题。修复
Stardust/StarClient.cs:Execute的ProcessStartInfo增加CreateNoWindow = trueStardust/StarClient.Linux.cs:ExecuteWithStdErr同步补上,与StarClient.OSX.cs中ExecuteOSX已有的设置保持一致CreateNoWindow仅在UseShellExecute = false的 Windows 进程启动时生效(本处已满足),对 Linux / macOS 无副作用。复现与验证
new StarClient(server).GetNodeInfo(),可观察到wmic.exe进程被创建,GUI 进程随即闪现控制台窗口wmic.exe启动后,窗口闪现随之消失,确认来源就是该进程ExecuteOSX的既有写法一致,属于最小修复备注
若后续希望进一步减少进程启动,也可以考虑在 DXGI / PDH 获取失败时直接返回空结果而不是回退到 wmic;本 PR 只处理控制台窗口闪现问题。