首页 > 代码库 > Wince动态加载字体资源
Wince动态加载字体资源
#define SUB_KEY L"SOFTWARE\\Microsoft\\FontLink\\SystemLink" //子键 #define KEY_VALUE L"\\NANDFLASH\\YeedonMedia\\Font\\msyh.ttf,微软雅黑" //键值 #define FONT_PATH L"\\NANDFLASH\\YeedonMedia\\Font\\msyh.ttf"//字体路径 void ResetFontRegedit() { DWORD dwIndex = 0, NameSize, NameCnt, NameMaxLen, Type; DWORD KeySize, KeyCnt, KeyMaxLen, DateSize, MaxDateLen; WCHAR *szKeyName; WCHAR *szValueName; LPBYTE szValueDate; HKEY hKey = NULL; LONG nResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, SUB_KEY, 0, KEY_ALL_ACCESS, &hKey); if(nResult != ERROR_SUCCESS) { printf("打开注册表失败! RegOpenKeyEx return %d, GetLastError() return %d", nResult, GetLastError()); } //获取子键信息 if(RegQueryInfoKey(hKey, NULL, NULL, NULL, &KeyCnt, &KeyMaxLen, NULL, &NameCnt, &NameMaxLen, &MaxDateLen, NULL, NULL) != ERROR_SUCCESS) { printf("(RegQueryInfoKey错误! GetLastError() return %d", GetLastError()); ::RegCloseKey(hKey); } //枚举键值信息 for(dwIndex = 0; dwIndex < NameCnt; dwIndex++)//枚举键值 { DateSize = MaxDateLen + 1; NameSize = NameMaxLen + 1; szValueName = (WCHAR*)malloc(NameSize); szValueDate = (LPBYTE)malloc(DateSize); RegEnumValue(hKey, dwIndex, szValueName, &NameSize, NULL, &Type, szValueDate, &DateSize);//读取键值 if(Type == REG_SZ) { //判断键值项类型并做其他修改 printf("%s\n", szValueName); RegSetValueEx(hKey, szValueName, 0, REG_SZ, (byte*)KEY_VALUE, sizeof(KEY_VALUE)); } } ::RegCloseKey(hKey); } void AddFontResource() { RemoveFontResource(); if(::AddFontResource(FONT_PATH) == 0) //加载字体失败 { printf("加载字体资源失败!\n"); } ::SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0); } void RemoveFontResource() { RemoveFontResource(FONT_PATH); ::SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0); }
Wince动态加载字体资源
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。