struct AutoFont { AutoFont(HFONT font = NULL) : hFont(font) { } ~AutoFont() { if (hFont != NULL) ::DeleteObject(static_cast(hFont)); } HFONT hFont; }; HFONT UtilGetShellFont() { static AutoFont s_shellfont; if (s_shellfont.hFont == NULL) { HFONT hGuiFont = static_cast(::GetStockObject(DEFAULT_GUI_FONT)); LOGFONT lfGuiFont = { 0 }; if (::GetObject(hGuiFont, sizeof(LOGFONT), &lfGuiFont) == sizeof(LOGFONT)) { _tcsncpy(lfGuiFont.lfFaceName, _T("MS Shell Dlg 2"), sizeof(lfGuiFont.lfFaceName) / sizeof(TCHAR)); lfGuiFont.lfFaceName[(sizeof(lfGuiFont.lfFaceName) / sizeof(TCHAR)) - 1] = '\0'; s_shellfont.hFont = ::CreateFontIndirect(&lfGuiFont); } } return s_shellfont.hFont; }