爲了獲得主題名稱,你可以調用非託管GetCurrentThemeName方法:
public string GetThemeName()
{
StringBuilder themeNameBuffer = new StringBuilder(260);
var error = GetCurrentThemeName(themeNameBuffer, themeNameBuffer.Capacity, null, 0, null, 0);
if(error!=0) Marshal.ThrowExceptionForHR(error);
return themeNameBuffer.ToString();
}
[DllImport("uxtheme.dll", CharSet=CharSet.Auto)]
public static extern int GetCurrentThemeName(StringBuilder pszThemeFileName, int dwMaxNameChars, StringBuilder pszColorBuff, int dwMaxColorChars, StringBuilder pszSizeBuff, int cchMaxSizeChars);
您可以找到的版本和公鑰令牌右鍵單擊該主題.dll文件(如PresentationFramework.Aero) GAC(在Exporer中打開c:\ Windows \ Assembly),或者您可以使用代碼來執行此操作。
foreach(Assembly a in AppDomain.CurrentDomain.LoadedAssemblies)
if(a.Name.StartsWith("PresentationFramework."))
return a.FullName;
注意,通過加載的程序集循環還會告訴你目前的主題名稱如果主題只有一個已經被加載:在所有加載的程序集使用AppDomain.CurrentDomain.LoadedAssemblies,找到你想要的只是環在當前的AppDomain中。
出於好奇,你爲什麼要這麼做?你的程序的目的是什麼? – 2010-06-05 11:14:14