As my Christmas week side-project I thought I'd knock up a quick console app that I can run from the windows Start-up folder.
The application is going to delete some unwanted Global Corporate Desktop Icons (I like to run a clean deskt开发者_如何学Goop - is this common?) and Reset the Windows 7 Theme to my lovely Visual Studio 2010 graphics.
I have read the reasons why this shouldn't be done pro grammatically for the user but I feel this case is different as every morning I am manually deleting the icons and resetting the theme (policy is not stopping this - just reapplying it every morning) so I though this little side project could save me time in the long term.
I am deleting the Icons OK but I am struggling to set my theme ala:
Dim key As RegistryKey = My.Computer.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Themes", True)
key.SetValue("CurrentTheme", "C:\Users\myprofile\AppData\Local\Microsoft\Windows\Themes\VS2010.theme")
key.Close()
This is setting the registry key correctly but not applying it. Any suggestions as to how to make this work or alternatives would be appreciated. Ultimately I may try a simple Wallpaper Set but I would like to use the theme if possible!
Thanks
You'll have to P/Invoke to make that change. You'll need to use the SetSystemVisualStyle
method.
<DllImport("UxTheme.DLL", BestFitMapping:=False, CallingConvention:=CallingConvention.Winapi, CharSet:=CharSet.Unicode, EntryPoint:="#65")> _
Shared Function SetSystemVisualStyle(ByVal pszFilename As String, ByVal pszColor As String, ByVal pszSize As String, ByVal dwReserved As Integer) As Integer
End Function
SetSystemVisualStyle("C:\WINDOWS\resources\Themes\Luna\Luna.msstyles", "Metallic", "NormalSize", 0)
PInvoke.net is giving me problems right now so you might need to used the cached page.
精彩评论