private SortedDictionary<string, string> ReadFontInformation()
{
var dictionary = new SortedDictionary<string, string>();
RegistryKey mykey = Registry.LocalMachine;
// 打开注册表
RegistryKey mykeySub = mykey.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts", true);
//获取字体名
string[] mynames = mykeySub.GetValueNames();
foreach (string name in mynames)
{
//获取字体的文件名
string myvalue = mykeySub.GetValue(name).ToString();
if (myvalue.Substring(myvalue.Length - 4).ToUpper() == ".TTF" && myvalue.Substring(1, 2).ToUpper() != @":\")
{
string val = name.Substring(0, name.Length - 11);
dictionary[val] = myvalue;
}
}
mykeySub.Close();
return dictionary;
}
C#中根据注册表查找字体与字体文件路径对应关系
最新推荐文章于 2023-09-06 09:04:56 发布