In C # or VB.Net yet, knowing the declaration of the visual theme .theme , I would like to apply this visual theme on Windows, without , depending on other applications like RunDll32.exe , just P / Invoking, but avoiding weird / strange things, such as opening a personalization window, and then using FindWindow to close it, the procedure should be automated from a platform call that does not interact with other windows.
This question about how to apply the topic was asked in SO by many people (included by me, with a solution using registry modification plus stop / resume service, which works only under Windows 7), I think it’s time for an expert to demonstrate our approach WinAPI that does not include RunDll32.exe without opening a personalization window.
Interestingly, this can be done by setting some values in the registry HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager , and then sending / sending a message through SendMessage or PostMessage or another function or, possibly, reporting a change in the environment through the SendMessageTimeOut function or SHChangeNotify or SystemParametersInfo or another function, because in the uxtheme.dll library uxtheme.dll seems that there is nothing useful for this task, the question is which function and with what parameters the visual change of the theme is applied, there are some commercial applications that can About to do, what are the steps to do this ?, I tried all these functions without success.
This is the decision that I made for Windows 7 in the past, I remember that it is not ideal, because for some themes the colors were not applied properly and only allowed with re-entry into the user session in order to affect the changes properly after modifications
Private Sub SetAeroTheme(ByVal themeFile As String, Optional ByVal colorName As String = "NormalColor", Optional ByVal sizeName As String = "NormalSize") Dim regKeyPath As String = "Software\Microsoft\Windows\CurrentVersion\ThemeManager" Using themeService As New ServiceController("Themes") If themeService.Status = ServiceControllerStatus.Running Then themeService.Stop() themeService.WaitForStatus(ServiceControllerStatus.Stopped) End If Using regKey As RegistryKey = Registry.CurrentUser.OpenSubKey(regKeyPath, writable:=True) regKey.SetValue("LoadedBefore", "0", RegistryValueKind.String) regKey.SetValue("DllName", themeFile, RegistryValueKind.String) regKey.SetValue("ColorName", colorName, RegistryValueKind.String) regKey.SetValue("SizeName", sizeName, RegistryValueKind.String) End Using If themeService.Status = ServiceControllerStatus.Stopped Then themeService.Start() themeService.WaitForStatus(ServiceControllerStatus.Running) End If End Using End Sub
On Windows 8, I think that since the composition of DWM is changing, this code no longer works.