如何在运行时将当前主题更改为Window7中的Window经典主题

时间:2012-05-08 03:39:10

标签: c# asp.net windows-7

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

关于,

1 个答案:

答案 0 :(得分: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.
}