Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Change Windows XP Desktop Theme using ThemeUI.dll functions

Posted on 2005-04-20
11
Medium Priority
?
8,447 Views
Last Modified: 2012-08-13
Hi,

I want to be able to change the Windows XP Desktop theme (Not Current App) using any possible methods. I have found out that ThemeUI.dll controls this and also provides the preview window when a theme is selected, MS have not published the Function calls for this dll and information is all but non existant on google and the developer web sites. I did find this post on Experts Exchange but have been unsuccessful at gettig it to work,

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21172764.html

The reason I wish to do this is so that I can provide several corporate themes for my company whilst stopping users from being able to install any themes that have not been approved. Group policy is not an option as it only disables the theme tab and forces a specific theme.

Any help on this would be greatly appreciated, I will give 500 points to anyone who can resolve this issue...
0
Comment
Question by:Haggard1
  • 6
  • 4
11 Comments
 
LVL 29

Expert Comment

by:Michael Pfister
ID: 13831173
you can just call a theme by "running" it, the shell takes care of the rest.

i.e. in VBS set the classic style :

------ cut and save as ChgTheme.vbs -------------
set shell=createobject("wscript.shell")
shell.run """C:\Windows\Resources\Themes\Windows Classic.theme"""
WScript.Sleep 1000
shell.sendkeys "{ENTER}"
wscript.quit
---------------------------------------------------------
Disadvantage: a dialog box pops up for a few seconds, but the scripts sends an enter key to close it. A user could click somewhere else and the enter key goes to the wrong place.

Hope this helps.

Michael
0
 
LVL 1

Author Comment

by:Haggard1
ID: 13831192
Unfortunately this won't work as Group Policy will be enabled which will disable the Themes dialogue page.
0
 
LVL 29

Expert Comment

by:Michael Pfister
ID: 13832530
I couldn't find anything regarding an API for ThemeUI.dll ... the only thing where you could start is modify the registry. The regfile you see here will switch the user from classic to Luna style, but only after logoff/logon.
So you could export the settings for the different styles you want to offer, let the user select one, import the according registry entries and tell the user to log off and log on again.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager]
"ThemeActive"="1"
"LoadedBefore"="1"
"LastUserLangID"="1031"
"DllName"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,\
  74,00,25,00,5c,00,72,00,65,00,73,00,6f,00,75,00,72,00,63,00,65,00,73,00,5c,\
  00,54,00,68,00,65,00,6d,00,65,00,73,00,5c,00,6c,00,75,00,6e,00,61,00,5c,00,\
  6c,00,75,00,6e,00,61,00,2e,00,6d,00,73,00,73,00,74,00,79,00,6c,00,65,00,73,\
  00,00,00
"ColorName"="NormalColor"
"SizeName"="NormalSize"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes]
"InstallTheme"=hex(2):25,00,52,00,65,00,73,00,6f,00,75,00,72,00,63,00,65,00,44,\
  00,69,00,72,00,25,00,5c,00,74,00,68,00,65,00,6d,00,65,00,73,00,5c,00,4c,00,\
  75,00,6e,00,61,00,2e,00,74,00,68,00,65,00,6d,00,65,00,00,00
"InstallVisualStyle"=hex(2):25,00,52,00,65,00,73,00,6f,00,75,00,72,00,63,00,65,\
  00,44,00,69,00,72,00,25,00,5c,00,74,00,68,00,65,00,6d,00,65,00,73,00,5c,00,\
  4c,00,75,00,6e,00,61,00,5c,00,4c,00,75,00,6e,00,61,00,2e,00,6d,00,73,00,73,\
  00,74,00,79,00,6c,00,65,00,73,00,00,00
"InstallVisualStyleColor"="NormalColor"
"InstallVisualStyleSize"="NormalSize"
"SetupVersion"="7"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\DefaultVisualStyleOff]
"InstallVisualStyle"=hex(2):00,00
"InstallVisualStyleColor"="Windows Standard"
"InstallVisualStyleSize"="Normal"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\DefaultVisualStyleOn]
"InstallVisualStyle"=hex(2):25,00,52,00,65,00,73,00,6f,00,75,00,72,00,63,00,65,\
  00,44,00,69,00,72,00,25,00,5c,00,74,00,68,00,65,00,6d,00,65,00,73,00,5c,00,\
  4c,00,75,00,6e,00,61,00,5c,00,4c,00,75,00,6e,00,61,00,2e,00,6d,00,73,00,73,\
  00,74,00,79,00,6c,00,65,00,73,00,00,00
"InstallVisualStyleColor"="NormalColor"
"InstallVisualStyleSize"="NormalSize"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\LastTheme]
"ThemeFile"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,\
  74,00,25,00,5c,00,72,00,65,00,73,00,6f,00,75,00,72,00,63,00,65,00,73,00,5c,\
  00,54,00,68,00,65,00,6d,00,65,00,73,00,5c,00,4c,00,75,00,6e,00,61,00,2e,00,\
  74,00,68,00,65,00,6d,00,65,00,00,00
"Wallpaper"=hex(2):00,00
"DisplayName of Modified"=""
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 29

Accepted Solution

by:
Michael Pfister earned 2000 total points
ID: 13833224
I've looked at the Delphi sample you noted in your post and was able to transalte it to a  VBScript:

----------------- cut and save as Theme.vbs ------------------

Option Explicit

Dim objMGR
Dim objItem
Dim i


set objMGR=createobject("Theme.Manager")

For i = 0 to objMGR.Length-1

      Wscript.Echo objMGR.Item(i).DisplayName
      If objMGR.Item(i).DisplayName = "Windows Classic" Then
        objMGR.SelectedTheme = objMGR.Item(i)
          objMGR.ApplyNow
        
      End If

Next
wscript.quit
---------------------------------

When run with cscript Theme.vbs it will list all available themes and select the classic style (you might have to adjust the string between the "" to match the exact writing, I have a workstation with a MUI, so it might be wrong.
I hope that rllibby has no copyright on his Delphi code?!?! :-)
0
 
LVL 1

Author Comment

by:Haggard1
ID: 13834388
Hi MPFISTER,

When I run the code I get and error Permission denied:'Length' Line:10 Char:9 which is line For i = 0 to objMGR.Length-1 for me...

I'm a local Admin on the box I'm on any idea's, you ran this and it worked?

Cheers

0
 
LVL 29

Expert Comment

by:Michael Pfister
ID: 13837086
This is strange: on the box I wrote this script it worked just fine. On my box at home it displays the same error ...
0
 
LVL 29

Expert Comment

by:Michael Pfister
ID: 13838361
I found it: my machine at home has XP SP2 on it, the machine the script worked before had XP SP1.

I renamed C:\WINDOWS\system32\themeui.dll on my home machine and replaced it with the themeui.dll from a Windows XP SP1 CD and the script worked!
I have no idea what could cause this...




0
 
LVL 1

Author Comment

by:Haggard1
ID: 13839771
Hi again,

Thanks for your help so far ; )

I've been looking at XP SP2 security, I think it might be to do with it not running as a system account or in the right security context. Any idea's...
0
 
LVL 1

Author Comment

by:Haggard1
ID: 13839880
I've opened another question if you want to have a crack a the points available, it's another 500 : )

http://www.experts-exchange.com/Programming/Q_21398325.html 
0
 
LVL 29

Expert Comment

by:Michael Pfister
ID: 13840359
Thanks for the points, Haggard1.
I've already looked at DCOM security, file security and registry security, I think somethings messed up with SP2s  ThemeUI.dll. I'd like to ask MS but the API is not officially supported (nothing on MSDN).
0
 
LVL 2

Expert Comment

by:thor918
ID: 21141011
dosen't seem better with sp3 either.

http://www.microsoft.com/downloads/details.aspx?FamilyId=114F3599-12AF-42B2-AAB1-B969A62C68A7&displaylang=en

anyone got a better solution, that does not require a dll change?

I have experiented with some windows python api to custimize some of the settings, but I met the wall. the api dosent seem to work.
http://www.experts-exchange.com/Programming/Languages/Scripting/Python/Q_23238537.html
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally Windows/Microsoft Updates will fail to update. We have found a code that will delete all temporary files and re-register all dll's related to Windows/Microsoft Updates! This works 99% of the time to get the updates working again! The…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension . This reminded me of questions that come up here at EE along the lines of, "How can I tell the type of file from its cont…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question