//功能函数 #include <vector> using namespace std; vector<CString> g_vSysFonts; INT CALLBACK NEnumFontNameProc(LOGFONT* plf, TEXTMETRIC* /*ptm*/, INT /*nFontType*/, LPARAM lParam/**/) { //同步调用的回调 vector<CString>* sysFonts = (vector<CString>*)lParam; CString strVal(L""); if (sysFonts != NULL) { strVal = plf->lfFaceName; if (strVal.Left(1) != L"@") { sysFonts->push_back(strVal); } } return TRUE; //EnumFontFamilies 返回值由此回调返回决定 } void GetSystemFont(HWND& hwnd) { vector<CString> vFont; HDC hdc = ::GetDC(hwnd); // int nRet = ::EnumFontFamilies(hdc, (LPTSTR)NULL, (FONTENUMPROC)NEnumFontNameProc, (LPARAM) & (g_vSysFonts)); int nRet = ::EnumFonts(hdc, (LPTSTR)NULL, (FONTENUMPROC)NEnumFontNameProc, (LPARAM) & (g_vSysFonts)); ::ReleaseDC(hwnd, hdc); } // 调用函数 GetSystemFont(m_hWnd); for (vector<CString>::iterator it = g_vSysFonts.begin();it!=g_vSysFonts.end();it++) { CString css = *it; if (css.MakeLower().Find(L"le")!=-1) { AfxMessageBox(css); } }