1

我正在使用 ASP.net 和 C# 。现在,我开发了一个 Web 应用程序。我想在 Window7(IE8) 中将当前主题更改为 windows 经典主题,因为在使用其他主题时我的设计是无序的。我可以在运行时更改主题吗?我可以做这个 OnPreInit() 事件吗?请帮我 。

带着敬意,

4

1 回答 1

2

您应该修复您的 CSS 而不是更改整个 Windows 主题以使其正常工作...

另外,您不能从 ASP.Net 在客户端上启动进程,但这里是非 Web 应用程序的答案:

参考:http ://davidrobertmattson.com/wordpress/?p=48

//Sets the current theme
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.FileName = “rundll32.exe”;
string startuppath = Application.StartupPath.ToString();
string Arguments = “Shell32.dll,Control_RunDLL desk.cpl desk,@Themes /Action:OpenTheme /File:\”C:\\Windows\\Resources\\Themes\\Windows Classic.Theme\”";
startInfo.Arguments = Arguments;
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForInputIdle();

IntPtr p = exeProcess.MainWindowHandle;
ShowWindow(p, 1);
SendKeys.SendWait(“{enter}”);
}
}
catch
{
// Log error.
}
于 2012-05-08T03:47:40.397 回答