更改C#中的Windows主题

发布于 2025-01-21 12:40:28 字数 875 浏览 0 评论 0 原文

我不知道如何解释...自定义的窗口主题,我可以从任何一个中应用它们:从

  • cmd中轻松打开.theme文件
  • :call%windir%\ resources \ themes \ shady \ shady.theme
  • 。表达式“ C:\ Windows \ Resources \ Themes \ shady.theme”,

但是当我将其中的任何一个与C#一起使用时,它正在打破主题 - 不要完全应用它。我尝试运行动词,尝试制作ps1,bat文件并使用C#运行,但仍然存在同样的问题...请参阅这些屏幕截图以了解我的代码的意思

string tokyo1 = "call " + '\u0022' + @"%windir%\Resources\Themes\Tokyo Night.theme" + '\u0022';
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = "/c " + tokyo1;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.Verb = "runas";
process.Start();

带有cmd,powershell,powerShell,theme file

I don't know how to explain...Custom windows themes, I can apply them from any of this:

  • Open the .theme file easily
  • From CMD : call %windir%\Resources\Themes\Shady.theme
  • From Powershell : Invoke-Expression "C:\Windows\Resources\Themes\Shady.theme"

but when I use any of this with C# it's breaking the theme - not applying it completely. I tried Verb run as , Tried Making a ps1, bat files and run it with C# but still the same problem... See these screen Shots to understand what I mean

my code:

string tokyo1 = "call " + '\u0022' + @"%windir%\Resources\Themes\Tokyo Night.theme" + '\u0022';
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = "/c " + tokyo1;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.Verb = "runas";
process.Start();

With C#
With cmd,powershell,theme file

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤城病女 2025-01-28 12:40:28

我假设您只是使用cmd.exe执行的shell执行,因此您无需确定应该打开.THEME文件的程序。但这可以更简单地完成,而无需致电cmd.exe之前:

  var windir = Environment.GetEnvironmentVariable ("windir");
  var filename = Path.Combine (windir, "Resources\\Themes\\Shady.theme");
  System.Diagnostics.Process.Start (filename);

I assume you are just using shell execute from cmd.exe so that you don't need to decide what program should open the .theme file. But that could be done more easyly without calling cmd.exe before just do this:

  var windir = Environment.GetEnvironmentVariable ("windir");
  var filename = Path.Combine (windir, "Resources\\Themes\\Shady.theme");
  System.Diagnostics.Process.Start (filename);
墨落画卷 2025-01-28 12:40:28

感谢所有试图提供帮助的人。

我修复了!

只使用Windows表单应用程序
“仅使用的Windows

不是旧的

Thanks for all who tried to help.

I Fixed it !

Just Used Windows Forms App
Just Used Windows Forms App

Not the old one

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文