如何获取Windows 7主题名称 [英] How to get the Windows 7 theme name

查看:178
本文介绍了如何获取Windows 7主题名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows 7自带的几个内置的主题。他们可以通过右键单击桌面,选择个性化访问。在个性化,有一个包含像建筑,自然等主题一节名字的Aero主题。



我试着使用的uxtheme.dll的GetCurrentThemeName,但它的实际上是给样式名称:
C:\Windows\resources\Themes\Aero\Aero.msstyles除非我的当前主题设置为Windows基础,在这种情况下,它返回一个空字符串。是否有实际返回的主题名称,如自然,结构等......



我试过的代码如下的API:



 函数[DllImport(的uxtheme,ExactSpelling = TRUE,字符集= CharSet.Unicode)] 
公众的extern静态的Int32 GetCurrentThemeName(StringBuilder的stringThemeName ,
INT lengthThemeName,StringBuilder的stringColorName,INT lengthColorName,
StringBuilder的stringSizeName,诠释lengthSizeName);

StringBuilder的stringThemeName =新的StringBuilder(260);
StringBuilder的stringColorName =新的StringBuilder(260);
StringBuilder的stringSizeName =新的StringBuilder(260);

的Int32 S = GetCurrentThemeName(stringThemeName,260,stringColorName,260,stringSizeName,260);


解决方案

在MSDN文档,它看起来像服用后一看 GetThemeDocumentationProperty 可能是你在找什么对。



您会希望结合主题文件通过传递SZ_THDOCPROP_DISPLAYNAME为使用它(你alreayd在注册表中找到),以及该方法的第二个参数



在另外这里是具有C#的方法包装用于p网站/调用电话:的 HTTP: //www.java2s.com/Open-Source/CSharp/2.6.4-mono-.net-core/System.Windows.Forms/System/Windows/Forms/VisualStyles/UXTheme.cs.htm



希望有所帮助。


Windows 7 comes with several built-in themes. They can be accessed by right-clicking the desktop and choosing Personalize. Under Personalize, there is a section names "Aero Themes" containing themes like "Architecture" "Nature" and so on.

I tried using uxtheme.dll's GetCurrentThemeName, but it's actually giving the style name: "C:\Windows\resources\Themes\Aero\Aero.msstyles" unless my current theme is set to Windows Basic, in which case it returns an empty string. Is there an API that actually returns the theme name, like "Nature" "Architecture" etc...?

The code I tried is as follows:

[DllImport("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)] 
public extern static Int32 GetCurrentThemeName(StringBuilder stringThemeName, 
    int lengthThemeName, StringBuilder stringColorName, int lengthColorName, 
    StringBuilder stringSizeName, int lengthSizeName);

    StringBuilder stringThemeName = new StringBuilder(260);
    StringBuilder stringColorName = new StringBuilder(260);
    StringBuilder stringSizeName = new StringBuilder(260);

    Int32 s = GetCurrentThemeName(stringThemeName, 260,stringColorName, 260,stringSizeName, 260);

解决方案

After taking a look at the MSDN documentation it looks like GetThemeDocumentationProperty might be what you are looking for.

You'll want to use it in conjunction with the theme file (which you alreayd have found in the registry) as well as by passing in the SZ_THDOCPROP_DISPLAYNAME as the second parameter of the method.

In addition here is a site that has the c# method wrapper for the p/invoke call: http://www.java2s.com/Open-Source/CSharp/2.6.4-mono-.net-core/System.Windows.Forms/System/Windows/Forms/VisualStyles/UXTheme.cs.htm

Hope that helps.

这篇关于如何获取Windows 7主题名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆