ReactOS  r75619
fontsub.cpp
Go to the documentation of this file.
1 // FontSub by Katayama Hirofumi MZ
2 //
3 // To the extent possible under law, the person who associated CC0 with
4 // FontSub has waived all copyright and related or neighboring rights
5 // to FontSub.
6 //
7 // You should have received a copy of the CC0 legalcode along with this
8 // work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
9 
10 
11 #include <windows.h>
12 #include <windowsx.h>
13 #include <commctrl.h>
14 #include <tchar.h>
15 #include <vector> // for std::vector
16 #include <set> // for std::set
17 #include <string> // for std::basic_string
18 #include <algorithm> // for std::sort
19 #include <cstdio>
20 #include <cstring>
21 #include <cassert>
22 #include "resource.h"
23 
24 
25 #define NAME_COLUMN_WIDTH 250
26 #define SUB_COLUMN_WIDTH 250
27 #define MAX_STRING 120
28 
29 #ifndef _countof
30  #define _countof(array) (sizeof(array) / sizeof(array[0]))
31 #endif
32 
33 typedef std::wstring STRING;
34 
35 struct ITEM
36 {
39  ITEM(const STRING& Name, const STRING& Substitute,
40  BYTE CharSet1, BYTE CharSet2)
41  : m_Name(Name), m_Substitute(Substitute),
42  m_CharSet1(CharSet1), m_CharSet2(CharSet2) { }
43 };
44 
45 /* global variables */
48 HICON g_hIcon = NULL;
53 
54 LPCWSTR g_pszClassName = L"ReactOS Font Substitutes Editor";
55 LPCWSTR g_pszFileHeader = L"Windows Registry Editor Version 5.00";
56 
60 
63 
65  L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes";
66 
67 typedef std::set<STRING> FONTNAMESET;
68 typedef std::vector<ITEM> ITEMVECTOR;
69 
76 
77 typedef struct CHARSET_ENTRY
78 {
82 
84 {
85  { DEFAULT_CHARSET, L"DEFAULT_CHARSET (1)" },
86  { ANSI_CHARSET, L"ANSI_CHARSET (0)" },
87  { SYMBOL_CHARSET, L"SYMBOL_CHARSET (2)" },
88  { SHIFTJIS_CHARSET, L"SHIFTJIS_CHARSET (128)" },
89  { HANGUL_CHARSET, L"HANGUL_CHARSET (129)" },
90  { GB2312_CHARSET, L"GB2312_CHARSET (134)" },
91  { CHINESEBIG5_CHARSET, L"CHINESEBIG5_CHARSET (136)" },
92  { OEM_CHARSET, L"OEM_CHARSET (255)" },
93  { JOHAB_CHARSET, L"JOHAB_CHARSET (130)" },
94  { HEBREW_CHARSET, L"HEBREW_CHARSET (177)" },
95  { ARABIC_CHARSET, L"ARABIC_CHARSET (178)" },
96  { GREEK_CHARSET, L"GREEK_CHARSET (161)" },
97  { TURKISH_CHARSET, L"TURKISH_CHARSET (162)" },
98  { VIETNAMESE_CHARSET, L"VIETNAMESE_CHARSET (163)" },
99  { THAI_CHARSET, L"THAI_CHARSET (222)" },
100  { EASTEUROPE_CHARSET, L"EASTEUROPE_CHARSET (238)" },
101  { RUSSIAN_CHARSET, L"RUSSIAN_CHARSET (204)" },
102  { MAC_CHARSET, L"MAC_CHARSET (77)" },
103  { BALTIC_CHARSET, L"BALTIC_CHARSET (186)" }
104 };
105 const WCHAR g_LongestName[] = L"CHINESEBIG5_CHARSET (136)";
106 
107 static void trim(STRING& str)
108 {
109  static const WCHAR Spaces[] = L" \t\r\n";
110  size_t i = str.find_first_not_of(Spaces);
111  size_t j = str.find_last_not_of(Spaces);
112  if (i == STRING::npos || j == STRING::npos)
113  {
114  str.clear();
115  }
116  else
117  {
118  str = str.substr(i, j - i + 1);
119  }
120 }
121 
122 static int CALLBACK
124  const NEWTEXTMETRICW *pntm,
125  int FontType,
126  LPARAM lParam)
127 {
128  switch (pelf->elfFullName[0])
129  {
130  case UNICODE_NULL: case L'@':
131  break;
132  default:
133  g_Names.insert((const WCHAR *)pelf->elfFullName);
134  }
135  switch (pelf->elfLogFont.lfFaceName[0])
136  {
137  case UNICODE_NULL: case L'@':
138  break;
139  default:
140  g_Names.insert(pelf->elfLogFont.lfFaceName);
141  }
142  return 1;
143 }
144 
146 {
147  g_Names.clear();
148 
149  LOGFONTW lf;
150  ZeroMemory(&lf, sizeof(lf));
152 
155  DeleteDC(hDC);
156 
157  return !g_Names.empty();
158 }
159 
160 inline bool ItemCompareByNameAscend(const ITEM& Item1, const ITEM& Item2)
161 {
162  return Item1.m_Name < Item2.m_Name;
163 }
164 
165 inline bool ItemCompareByNameDescend(const ITEM& Item1, const ITEM& Item2)
166 {
167  return Item1.m_Name > Item2.m_Name;
168 }
169 
170 inline bool ItemCompareBySubAscend(const ITEM& Item1, const ITEM& Item2)
171 {
172  return Item1.m_Substitute < Item2.m_Substitute;
173 }
174 
175 inline bool ItemCompareBySubDescend(const ITEM& Item1, const ITEM& Item2)
176 {
177  return Item1.m_Substitute > Item2.m_Substitute;
178 }
179 
180 void DoSort(INT iColumn, BOOL bAscendant = TRUE)
181 {
183  ZeroMemory(&Column, sizeof(Column));
184  Column.mask = LVCF_IMAGE | LVCF_SUBITEM;
185  Column.iImage = 2;
186  Column.iSubItem = 0;
187  ListView_SetColumn(g_hListView, 0, &Column);
188  Column.iSubItem = 1;
189  ListView_SetColumn(g_hListView, 1, &Column);
190 
191  switch (iColumn)
192  {
193  case 0:
194  Column.iSubItem = 0;
195  if (bAscendant)
196  {
197  std::sort(g_Items.begin(), g_Items.end(),
199  Column.iImage = 0;
200  ListView_SetColumn(g_hListView, 0, &Column);
201  }
202  else
203  {
204  std::sort(g_Items.begin(), g_Items.end(),
206  Column.iImage = 1;
207  ListView_SetColumn(g_hListView, 0, &Column);
208  }
209  break;
210  case 1:
211  Column.iSubItem = 1;
212  if (bAscendant)
213  {
214  std::sort(g_Items.begin(), g_Items.end(),
216  Column.iImage = 0;
217  ListView_SetColumn(g_hListView, 1, &Column);
218  }
219  else
220  {
221  std::sort(g_Items.begin(), g_Items.end(),
223  Column.iImage = 1;
224  ListView_SetColumn(g_hListView, 1, &Column);
225  }
226  break;
227  }
228  g_iSortColumn = iColumn;
229  g_bSortAscendant = bAscendant;
231 }
232 
234 {
236 
237  LV_ITEM Item;
238  ZeroMemory(&Item, sizeof(Item));
239  Item.mask = LVIF_PARAM;
240 
241  const INT Count = INT(g_Items.size());
242  for (INT i = 0; i < Count; ++i)
243  {
244  Item.iItem = i;
245  Item.iSubItem = 0;
246  Item.lParam = i;
247  ListView_InsertItem(hwnd, &Item);
248 
249  Item.iItem = i;
250  Item.iSubItem = 1;
251  Item.lParam = i;
252  ListView_InsertItem(hwnd, &Item);
253  }
254 }
255 
257 {
258  ITEMVECTOR Items;
259 
260  HKEY hKey = NULL;
262  if (hKey == NULL)
263  return FALSE;
264 
265  WCHAR szName[MAX_STRING], szValue[MAX_STRING];
266  DWORD cbName, cbValue;
267  for (DWORD dwIndex = 0; ; ++dwIndex)
268  {
269  cbName = sizeof(szName);
270  cbValue = sizeof(szValue);
271  LONG Error = RegEnumValueW(hKey, dwIndex, szName, &cbName,
272  NULL, NULL, (LPBYTE)szValue, &cbValue);
273  if (Error != ERROR_SUCCESS)
274  break;
275 
276  BYTE CharSet1 = DEFAULT_CHARSET, CharSet2 = DEFAULT_CHARSET;
277  LPWSTR pch;
278 
279  pch = wcsrchr(szName, L',');
280  if (pch)
281  {
282  *pch = 0;
283  CharSet1 = (BYTE)_wtoi(pch + 1);
284  }
285 
286  pch = wcsrchr(szValue, L',');
287  if (pch)
288  {
289  *pch = 0;
290  CharSet2 = (BYTE)_wtoi(pch + 1);
291  }
292 
293  ITEM Item(szName, szValue, CharSet1, CharSet2);
294  trim(Item.m_Name);
295  trim(Item.m_Substitute);
296  Items.push_back(Item);
297  }
298 
299  RegCloseKey(hKey);
300 
301  g_Items = Items;
303  DoSort(0, TRUE);
304  g_bModified = FALSE;
306 
307  return !g_Items.empty();
308 }
309 
311 {
312  return DoLoadNames() && DoLoadItems();
313 }
314 
315 void LV_InvalidateRow(HWND hwnd, INT iRow = -1)
316 {
317  if (iRow == -1)
318  iRow = ListView_GetNextItem(hwnd, -1, LVNI_SELECTED);
319  if (iRow == -1)
320  return;
321 
322  RECT Rect;
323  LPRECT GccIsWhining = &Rect;
324  ListView_GetItemRect(hwnd, iRow, GccIsWhining, LVIR_BOUNDS);
325  InvalidateRect(hwnd, &Rect, FALSE);
326 }
327 
329 {
332 
333  HIMAGELIST hImageList;
334  hImageList = ImageList_Create(12, 12, ILC_COLOR8 | ILC_MASK, 2, 2);
335 
336  HBITMAP hbm;
339  assert(hbm);
340  ImageList_AddMasked(hImageList, hbm, RGB(192, 192, 192));
341  DeleteObject(hbm);
342 
345  assert(hbm);
346  ImageList_AddMasked(hImageList, hbm, RGB(192, 192, 192));
347  DeleteObject(hbm);
348 
351  assert(hbm);
352  ImageList_AddMasked(hImageList, hbm, RGB(192, 192, 192));
353  DeleteObject(hbm);
354 
355  ListView_SetImageList(hwnd, hImageList, LVSIL_SMALL);
356 
358  ZeroMemory(&Column, sizeof(Column));
359  Column.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH | LVCF_IMAGE;
360  Column.fmt = LVCFMT_LEFT;
361 
362  Column.cx = NAME_COLUMN_WIDTH;
363  Column.pszText = g_szNameHead;
364  Column.iSubItem = 0;
365  Column.iImage = 0;
366  ListView_InsertColumn(hwnd, 0, &Column);
367 
368  Column.cx = SUB_COLUMN_WIDTH;
369  Column.pszText = g_szSubstituteHead;
370  Column.iSubItem = 1;
371  Column.iImage = 2;
372  ListView_InsertColumn(hwnd, 1, &Column);
373 
375  ListView_SetItemState(hwnd, 0, State, State);
376 
377  return TRUE;
378 }
379 
381 {
382  COMBOBOXEXITEMW Item;
383  ZeroMemory(&Item, sizeof(Item));
384  Item.mask = CBEIF_TEXT;
385 
386  FONTNAMESET::iterator it, end = g_Names.end();
387  for (it = g_Names.begin(); it != end; ++it)
388  {
389  Item.pszText = const_cast<LPWSTR>(it->c_str());
390  Item.iItem = ComboBox_GetCount(GetDlgItem(hwnd, cmb2));
391  SendDlgItemMessageW(hwnd, cmb2, CBEM_INSERTITEM, 0, (LPARAM)&Item);
392  }
393  SetDlgItemTextW(hwnd, edt1, g_strFontName.c_str());
394  SetDlgItemTextW(hwnd, cmb2, g_strSubstitute.c_str());
395 
396  const INT Count = _countof(g_CharSetList);
397  for (INT i = 0; i < Count; ++i)
398  {
399  Item.pszText = const_cast<LPWSTR>(g_CharSetList[i].DisplayName);
400  Item.iItem = ComboBox_GetCount(GetDlgItem(hwnd, cmb3));
401  SendDlgItemMessageW(hwnd, cmb3, CBEM_INSERTITEM, 0, (LPARAM)&Item);
402  Item.iItem = ComboBox_GetCount(GetDlgItem(hwnd, cmb4));
403  SendDlgItemMessageW(hwnd, cmb4, CBEM_INSERTITEM, 0, (LPARAM)&Item);
404  }
405 
406  SendDlgItemMessageW(hwnd, cmb3, CB_SETCURSEL, 0, 0);
407  SendDlgItemMessageW(hwnd, cmb4, CB_SETCURSEL, 0, 0);
408  for (INT i = 0; i < Count; ++i)
409  {
410  if (g_CharSet1 == g_CharSetList[i].CharSet)
411  {
413  }
414  if (g_CharSet2 == g_CharSetList[i].CharSet)
415  {
417  }
418  }
419 
420  SIZE siz;
424  DeleteDC(hDC);
425 
426  SendDlgItemMessageW(hwnd, cmb3, CB_SETHORIZONTALEXTENT, siz.cx + 16, 0);
427  SendDlgItemMessageW(hwnd, cmb4, CB_SETHORIZONTALEXTENT, siz.cx + 16, 0);
428 
430 
431  return TRUE;
432 }
433 
434 void LV_OnDelete(HWND hwnd, INT iRow = -1)
435 {
436  if (iRow == -1)
437  iRow = ListView_GetNextItem(hwnd, -1, LVNI_SELECTED);
438  if (iRow == -1)
439  return;
440 
442  ListView_SetItemState(g_hListView, iRow, State, State);
443 
444  WCHAR sz[MAX_STRING];
448  {
449  return;
450  }
451 
452  ListView_DeleteItem(hwnd, iRow);
453  g_Items.erase(g_Items.begin() + iRow);
454  g_bModified = TRUE;
455 
456  ListView_SetItemState(g_hListView, iRow, State, State);
457 
458  InvalidateRect(hwnd, NULL, TRUE);
459 }
460 
461 void EditDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
462 {
463  WCHAR szValue[MAX_STRING];
464  STRING str;
465  INT i;
466 
467  switch (id)
468  {
469  case IDOK:
470  GetDlgItemTextW(hwnd, cmb2, szValue, _countof(szValue));
471  str = szValue;
472  trim(str);
473  if (str.empty())
474  {
475  WCHAR sz[MAX_STRING];
477  SetFocus(GetDlgItem(hwnd, cmb2));
479  MessageBoxW(hwnd, sz, NULL, MB_ICONERROR);
480  return;
481  }
482 
483  g_Items[g_iItem].m_CharSet2 = DEFAULT_CHARSET;
484  i = SendDlgItemMessageW(hwnd, cmb4, CB_GETCURSEL, 0, 0);
485  if (i != CB_ERR)
486  {
487  g_Items[g_iItem].m_CharSet2 = g_CharSetList[i].CharSet;
488  }
489  g_Items[g_iItem].m_Substitute = str;
490 
491  g_bModified = TRUE;
492  EndDialog(hwnd, IDOK);
493  break;
494  case IDCANCEL:
495  EndDialog(hwnd, IDCANCEL);
496  break;
497  case psh1:
499  EndDialog(hwnd, psh1);
500  break;
501  }
502 }
503 
506 {
507  switch (uMsg)
508  {
511  }
512  return 0;
513 }
514 
516 {
518  if (g_iItem == -1)
519  return;
520 
521  g_strFontName = g_Items[g_iItem].m_Name;
522  g_strSubstitute = g_Items[g_iItem].m_Substitute;
523  g_CharSet1 = g_Items[g_iItem].m_CharSet1;
524  g_CharSet2 = g_Items[g_iItem].m_CharSet2;
525 
529 }
530 
532 {
533  DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_VSCROLL |
535  DWORD dwExStyle = WS_EX_CLIENTEDGE;
536  g_hListView = CreateWindowEx(dwExStyle, WC_LISTVIEW, NULL, dwStyle,
537  0, 0, 0, 0,
538  hwnd, (HMENU)1, g_hInstance, NULL);
539  if (g_hListView == NULL)
540  return FALSE;
541 
542  if (!LV_Init(g_hListView))
543  return FALSE;
544 
545  if (!DoLoad())
546  return FALSE;
547 
549  ListView_SetItemState(g_hListView, 0, State, State);
551  return TRUE;
552 }
553 
555 {
556  COMBOBOXEXITEMW Item;
557  ZeroMemory(&Item, sizeof(Item));
558  Item.iItem = -1;
559  Item.mask = CBEIF_TEXT;
560 
561  FONTNAMESET::iterator it, end = g_Names.end();
562  for (it = g_Names.begin(); it != end; ++it)
563  {
564  Item.pszText = const_cast<LPWSTR>(it->c_str());
565  Item.iItem = ComboBox_GetCount(GetDlgItem(hwnd, cmb1));
566  SendDlgItemMessageW(hwnd, cmb1, CBEM_INSERTITEM, 0, (LPARAM)&Item);
567  Item.iItem = ComboBox_GetCount(GetDlgItem(hwnd, cmb2));
568  SendDlgItemMessageW(hwnd, cmb2, CBEM_INSERTITEM, 0, (LPARAM)&Item);
569  }
570  WCHAR szEnterName[MAX_STRING];
571  LoadStringW(g_hInstance, IDS_ENTERNAME, szEnterName, _countof(szEnterName));
572  SetDlgItemTextW(hwnd, cmb1, szEnterName);
574 
575  const INT Count = _countof(g_CharSetList);
576  for (INT i = 0; i < Count; ++i)
577  {
578  Item.pszText = const_cast<LPWSTR>(g_CharSetList[i].DisplayName);
579  Item.iItem = ComboBox_GetCount(GetDlgItem(hwnd, cmb3));
580  SendDlgItemMessageW(hwnd, cmb3, CBEM_INSERTITEM, 0, (LPARAM)&Item);
581  Item.iItem = ComboBox_GetCount(GetDlgItem(hwnd, cmb4));
582  SendDlgItemMessageW(hwnd, cmb4, CBEM_INSERTITEM, 0, (LPARAM)&Item);
583  }
584 
585  SendDlgItemMessageW(hwnd, cmb3, CB_SETCURSEL, 0, 0);
586  SendDlgItemMessageW(hwnd, cmb4, CB_SETCURSEL, 0, 0);
587  for (INT i = 0; i < Count; ++i)
588  {
589  if (g_CharSet1 == g_CharSetList[i].CharSet)
590  {
592  }
593  if (g_CharSet2 == g_CharSetList[i].CharSet)
594  {
596  }
597  }
598 
599  SIZE siz;
603  DeleteDC(hDC);
604 
605  SendDlgItemMessageW(hwnd, cmb3, CB_SETHORIZONTALEXTENT, siz.cx + 16, 0);
606  SendDlgItemMessageW(hwnd, cmb4, CB_SETHORIZONTALEXTENT, siz.cx + 16, 0);
607 
608  return TRUE;
609 }
610 
611 void AddDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
612 {
613  WCHAR szKey[MAX_STRING], szValue[MAX_STRING], sz[MAX_STRING];
614  INT i, iCharSet1, iCharSet2;
615  BYTE CharSet1, CharSet2;
616  STRING key, value;
617  switch (id)
618  {
619  case IDOK:
620  GetDlgItemTextW(hwnd, cmb1, szKey, _countof(szKey));
621  key = szKey;
622  trim(key);
624  if (key.empty() || key == sz)
625  {
627  SetFocus(GetDlgItem(hwnd, cmb1));
629  MessageBoxW(hwnd, sz, NULL, MB_ICONERROR);
630  return;
631  }
632 
633  GetDlgItemTextW(hwnd, cmb2, szValue, _countof(szValue));
634  value = szValue;
635  trim(value);
636  if (value.empty())
637  {
639  SetFocus(GetDlgItem(hwnd, cmb2));
641  MessageBoxW(hwnd, sz, NULL, MB_ICONERROR);
642  return;
643  }
644 
645  iCharSet1 = SendDlgItemMessageW(hwnd, cmb3, CB_GETCURSEL, 0, 0);
646  if (iCharSet1 == CB_ERR)
647  iCharSet1 = 0;
648  iCharSet2 = SendDlgItemMessageW(hwnd, cmb4, CB_GETCURSEL, 0, 0);
649  if (iCharSet2 == CB_ERR)
650  iCharSet2 = 0;
651 
652  CharSet1 = g_CharSetList[iCharSet1].CharSet;
653  CharSet2 = g_CharSetList[iCharSet2].CharSet;
654 
655  for (i = 0; i < (INT)g_Items.size(); ++i)
656  {
657  if (g_Items[i].m_Name == key &&
658  g_Items[i].m_CharSet1 == CharSet1)
659  {
660  WCHAR sz[MAX_STRING];
662  SetFocus(GetDlgItem(hwnd, cmb1));
664  MessageBoxW(hwnd, sz, NULL, MB_ICONERROR);
665  return;
666  }
667  }
668  {
669  ITEM Item(key, value, CharSet1, CharSet2);
670  g_Items.push_back(Item);
671  g_bModified = TRUE;
672 
673  i = (INT)g_Items.size();
674  LV_ITEM LvItem;
675  ZeroMemory(&LvItem, sizeof(LvItem));
676  LvItem.mask = LVIF_PARAM;
677  LvItem.iItem = i;
678  LvItem.lParam = i;
679 
680  LvItem.iSubItem = 0;
682 
683  LvItem.iSubItem = 1;
685  }
686  g_bModified = TRUE;
687  EndDialog(hwnd, IDOK);
688  break;
689  case IDCANCEL:
690  EndDialog(hwnd, IDCANCEL);
691  break;
692  }
693 }
694 
697 {
698  switch (uMsg)
699  {
702  }
703  return 0;
704 }
705 
707 {
709  if (g_iItem == -1)
710  return;
711 
712  g_strFontName = g_Items[g_iItem].m_Name;
713  g_strSubstitute = g_Items[g_iItem].m_Substitute;
714  g_CharSet1 = g_Items[g_iItem].m_CharSet1;
715  g_CharSet2 = g_Items[g_iItem].m_CharSet2;
716 
719  {
722  ListView_SetItemState(g_hListView, i, State, State);
724  }
725 }
726 
728 {
729  // open the key
730  HKEY hKey = NULL;
732  if (hKey == NULL)
733  return FALSE;
734 
735  // clear all values
736  WCHAR szName[MAX_STRING], szValue[MAX_STRING];
737  DWORD cbName, cbValue;
738  for (;;)
739  {
740  cbName = sizeof(szName);
741  cbValue = sizeof(szValue);
742  LONG Error = RegEnumValueW(hKey, 0, szName, &cbName,
743  NULL, NULL, (LPBYTE)szValue, &cbValue);
744  if (Error != ERROR_SUCCESS)
745  break;
746 
747  RegDeleteValueW(hKey, szName);
748  }
749 
750  // set values
751  size_t Count = g_Items.size();
752  for (size_t i = 0; i < Count; ++i)
753  {
754  DWORD cbData = (g_Items[i].m_Substitute.size() + 1) * sizeof(WCHAR);
755  RegSetValueExW(hKey, g_Items[i].m_Name.c_str(), 0,
756  REG_SZ, (LPBYTE)g_Items[i].m_Substitute.c_str(), cbData);
757  }
758 
759  // close now
760  RegCloseKey(hKey);
761 
762  g_bModified = FALSE;
764  return TRUE;
765 }
766 
768 {
769  while (*pch && wcschr(L" \t\r\n", *pch) != NULL)
770  {
771  ++pch;
772  }
773  return const_cast<LPWSTR>(pch);
774 }
775 
777 {
778  ++pch; // L'"'
779  while (*pch)
780  {
781  if (*pch == L'"')
782  {
783  ++pch;
784  break;
785  }
786  if (*pch == L'\\')
787  {
788  ++pch;
789  }
790  ++pch;
791  }
792  return pch;
793 }
794 
795 void UnescapeHex(const STRING& str, size_t& i, STRING& Ret, BOOL Unicode)
796 {
797  STRING Num;
798 
799  // hexadecimal
800  if (iswxdigit(str[i]))
801  {
802  Num += str[i];
803  ++i;
804  if (iswxdigit(str[i]))
805  {
806  Num += str[i];
807  ++i;
808  if (Unicode)
809  {
810  if (iswxdigit(str[i]))
811  {
812  Num += str[i];
813  ++i;
814  if (iswxdigit(str[i]))
815  {
816  Num += str[i];
817  ++i;
818  }
819  }
820  }
821  }
822  }
823  if (!Num.empty())
824  {
825  Ret += (WCHAR)wcstoul(&Num[0], NULL, 16);
826  }
827 }
828 
829 void UnescapeOther(const STRING& str, size_t& i, STRING& Ret)
830 {
831  STRING Num;
832 
833  // check octal
834  if (L'0' <= str[i] && str[i] < L'8')
835  {
836  Num += str[i];
837  ++i;
838  if (L'0' <= str[i] && str[i] < L'8')
839  {
840  Num += str[i];
841  ++i;
842  if (L'0' <= str[i] && str[i] < L'8')
843  {
844  Num += str[i];
845  ++i;
846  }
847  }
848  }
849  if (Num.empty())
850  {
851  Ret += str[i];
852  ++i;
853  }
854  else
855  {
856  // octal
857  Ret += (WCHAR)wcstoul(&Num[0], NULL, 8);
858  }
859 }
860 
861 // process escape sequence
862 void UnescapeChar(const STRING& str, size_t& i, STRING& Ret)
863 {
864  if (str[i] != L'\\')
865  {
866  Ret += str[i];
867  ++i;
868  return;
869  }
870 
871  ++i;
872  switch (str[i])
873  {
874  case L'a': Ret += L'\a'; ++i; break;
875  case L'b': Ret += L'\b'; ++i; break;
876  case L'f': Ret += L'\f'; ++i; break;
877  case L'n': Ret += L'\n'; ++i; break;
878  case L'r': Ret += L'\r'; ++i; break;
879  case L't': Ret += L'\t'; ++i; break;
880  case L'v': Ret += L'\v'; ++i; break;
881  case L'x':
882  // hexidemical
883  ++i;
884  UnescapeHex(str, i, Ret, FALSE);
885  break;
886  case L'u':
887  // Unicode hexidemical
888  ++i;
889  UnescapeHex(str, i, Ret, TRUE);
890  break;
891  default:
892  // other case
893  UnescapeOther(str, i, Ret);
894  break;
895  }
896 }
897 
899 {
900  if (str[0] != L'"')
901  return str;
902 
903  STRING Ret;
904  size_t i = 1;
905  while (i < str.size())
906  {
907  if (str[i] == L'"' || str[i] == UNICODE_NULL)
908  break;
909 
910  UnescapeChar(str, i, Ret);
911  }
912  return Ret;
913 }
914 
916 {
917  ITEMVECTOR Items;
918 
919  LPWSTR pch, pchSep, pchStart = (LPWSTR)pvContents;
920 
921  pchStart[dwSize / sizeof(WCHAR)] = UNICODE_NULL;
922 
923  // check header
924  const DWORD cbHeader = lstrlenW(g_pszFileHeader) * sizeof(WCHAR);
925  if (memcmp(pchStart, g_pszFileHeader, cbHeader) != 0)
926  return FALSE;
927 
928  pchStart += cbHeader / sizeof(WCHAR);
929 
930  // find the key
931  WCHAR szKey[MAX_STRING];
932  wsprintfW(szKey, L"[HKEY_LOCAL_MACHINE\\%s]", g_pszKey);
933  pch = wcsstr(pchStart, szKey);
934  if (pch == NULL)
935  return FALSE;
936 
937  pchStart = pch + lstrlenW(szKey);
938 
939  for (;;)
940  {
941  pchStart = SkipSpace(pchStart);
942  if (*pchStart == UNICODE_NULL || *pchStart == L'[')
943  break;
944 
945  pch = wcschr(pchStart, L'\n');
946  if (pch)
947  *pch = UNICODE_NULL;
948 
949  pchSep = SkipQuoted(pchStart);
950  if (*pchSep == L'=')
951  {
952  *pchSep = UNICODE_NULL;
953 
954  STRING key = pchStart;
955  trim(key);
956  key = Unquote(key);
957 
958  STRING value = pchSep + 1;
959  trim(value);
960  value = Unquote(value);
961 
962  BYTE CharSet1 = DEFAULT_CHARSET, CharSet2 = DEFAULT_CHARSET;
963 
964  size_t pos;
965  pos = key.find(L',');
966  if (pos != STRING::npos)
967  {
968  CharSet1 = (BYTE)_wtoi(&key[pos + 1]);
969  key.resize(pos);
970  trim(key);
971  }
972  pos = value.find(L',');
973  if (pos != STRING::npos)
974  {
975  CharSet2 = (BYTE)_wtoi(&value[pos + 1]);
976  value.resize(pos);
977  trim(value);
978  }
979 
980  ITEM Item(key, value, CharSet1, CharSet2);
981  Items.push_back(Item);
982  }
983 
984  if (pch == NULL)
985  break;
986 
987  pchStart = pch + 1;
988  }
989 
990  g_Items = Items;
991  g_bModified = TRUE;
992 
994  return TRUE;
995 }
996 
998 {
1002  if (hFile == INVALID_HANDLE_VALUE)
1003  return FALSE;
1004 
1005  BOOL bSuccess = FALSE;
1006  DWORD dwSize = GetFileSize(hFile, NULL);
1007  if (dwSize != 0xFFFFFFFF)
1008  {
1009  std::vector<BYTE> Contents(dwSize + 2);
1010  DWORD cbRead;
1011  if (ReadFile(hFile, &Contents[0], dwSize, &cbRead, NULL) &&
1012  cbRead == dwSize)
1013  {
1014  /* check BOM */
1015  if (memcmp(&Contents[0], "\xFF\xFE", 2) == 0)
1016  {
1017  bSuccess = DoParseFile(&Contents[2], dwSize - 2);
1018  }
1019  else
1020  {
1021  bSuccess = DoParseFile(&Contents[0], dwSize);
1022  }
1023  }
1024  }
1025  CloseHandle(hFile);
1026 
1027  return bSuccess;
1028 }
1029 
1031 {
1032  STRING Ret;
1033  for (size_t i = 0; i < str.size(); ++i)
1034  {
1035  switch (str[i])
1036  {
1037  case L'"': case L'\\':
1038  Ret += L'\\';
1039  Ret += str[i];
1040  break;
1041  default:
1042  Ret += str[i];
1043  }
1044  }
1045  return Ret;
1046 }
1047 
1049 {
1053  if (hFile == INVALID_HANDLE_VALUE)
1054  return FALSE;
1055 
1056  BOOL bSuccess;
1057  DWORD dwSize, cbWritten;
1058  WCHAR szCharSet1[MAX_STRING], szCharSet2[MAX_STRING];
1059  WCHAR szLine[MAX_STRING * 2 + 4];
1060 
1061  /* write header */
1062  dwSize = lstrlenW(g_pszFileHeader) * sizeof(WCHAR);
1063  bSuccess =
1064  WriteFile(hFile, "\xFF\xFE", 2, &cbWritten, NULL) &&
1065  WriteFile(hFile, g_pszFileHeader, dwSize, &cbWritten, NULL);
1066  if (bSuccess)
1067  {
1068  wsprintfW(szLine, L"\r\n\r\n[HKEY_LOCAL_MACHINE\\%s]\r\n", g_pszKey);
1069  dwSize = lstrlenW(szLine) * sizeof(WCHAR);
1070  bSuccess = WriteFile(hFile, szLine, dwSize, &cbWritten, NULL);
1071  }
1072  if (bSuccess)
1073  {
1074  size_t i, Count = g_Items.size();
1075  for (i = 0; i < Count; ++i)
1076  {
1077  if (g_Items[i].m_CharSet1 != DEFAULT_CHARSET)
1078  wsprintfW(szCharSet1, L",%u", g_Items[i].m_CharSet1);
1079  else
1080  szCharSet1[0] = UNICODE_NULL;
1081 
1082  if (g_Items[i].m_CharSet2 != DEFAULT_CHARSET)
1083  wsprintfW(szCharSet2, L",%u", g_Items[i].m_CharSet2);
1084  else
1085  szCharSet2[0] = UNICODE_NULL;
1086 
1087  STRING Name = Escape(g_Items[i].m_Name);
1088  STRING Substitute = Escape(g_Items[i].m_Substitute);
1089  wsprintfW(szLine, L"\"%s%s\"=\"%s%s\"\r\n",
1090  Name.c_str(), szCharSet1,
1091  Substitute.c_str(), szCharSet2);
1092 
1093  dwSize = lstrlenW(szLine) * sizeof(WCHAR);
1094  if (!WriteFile(hFile, szLine, dwSize, &cbWritten, NULL))
1095  {
1096  bSuccess = FALSE;
1097  break;
1098  }
1099  }
1100  WriteFile(hFile, L"\r\n", 2 * sizeof(WCHAR), &cbWritten, NULL);
1101  }
1102  CloseHandle(hFile);
1103 
1104  if (!bSuccess)
1105  {
1106  DeleteFileW(pszFile);
1107  }
1108 
1109  return bSuccess;
1110 }
1111 
1112 void MakeFilter(LPWSTR pszFilter)
1113 {
1114  while (*pszFilter)
1115  {
1116  if (*pszFilter == L'|')
1117  *pszFilter = 0;
1118 
1119  ++pszFilter;
1120  }
1121 }
1122 
1124 {
1125  OPENFILENAMEW ofn = {0};
1126  WCHAR szFile[MAX_PATH] = L"";
1127  WCHAR szImportTitle[MAX_STRING];
1128  WCHAR szCannotImport[MAX_STRING];
1129  WCHAR szImportFilter[MAX_STRING];
1130  LoadStringW(g_hInstance, IDS_IMPORT, szImportTitle, _countof(szImportTitle));
1131  LoadStringW(g_hInstance, IDS_CANTIMPORT, szCannotImport, _countof(szCannotImport));
1132  LoadStringW(g_hInstance, IDS_INPFILTER, szImportFilter, _countof(szImportFilter));
1133  MakeFilter(szImportFilter);
1134 
1136  ofn.hwndOwner = hwnd;
1137  ofn.lpstrFilter = szImportFilter;
1138  ofn.lpstrFile = szFile;
1139  ofn.nMaxFile = _countof(szFile);
1140  ofn.lpstrTitle = szImportTitle;
1145  ofn.lpstrDefExt = L"reg";
1146  if (GetOpenFileNameW(&ofn))
1147  {
1148  if (!DoImport(hwnd, szFile))
1149  {
1150  MessageBoxW(hwnd, szCannotImport, g_szTitle, MB_ICONERROR);
1151  }
1152  }
1153 }
1154 
1156 {
1157  OPENFILENAMEW ofn = {0};
1158  WCHAR szFile[MAX_PATH] = L"";
1159  WCHAR szExportTitle[MAX_STRING];
1160  WCHAR szCannotExport[MAX_STRING];
1161  WCHAR szExportFilter[MAX_STRING];
1162  LoadStringW(g_hInstance, IDS_EXPORT, szExportTitle, _countof(szExportTitle));
1163  LoadStringW(g_hInstance, IDS_CANTEXPORT, szCannotExport, _countof(szCannotExport));
1164  LoadStringW(g_hInstance, IDS_OUTFILTER, szExportFilter, _countof(szExportFilter));
1165  MakeFilter(szExportFilter);
1166 
1168  ofn.hwndOwner = hwnd;
1169  ofn.lpstrFilter = szExportFilter;
1170  ofn.lpstrFile = szFile;
1171  ofn.nMaxFile = _countof(szFile);
1172  ofn.lpstrTitle = szExportTitle;
1176  ofn.lpstrDefExt = L"reg";
1177  if (GetSaveFileNameW(&ofn))
1178  {
1179  if (!DoExport(hwnd, szFile))
1180  {
1181  MessageBoxW(hwnd, szCannotExport, g_szTitle, MB_ICONERROR);
1182  }
1183  }
1184 }
1185 
1187 {
1188  DoLoad();
1189 }
1190 
1192 {
1194 }
1195 
1197 {
1199 }
1200 
1202 {
1203  static const WCHAR s_szRegeditKey[] =
1204  L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit";
1205  WCHAR sz[MAX_STRING];
1206 
1207  // open regedit key
1208  HKEY hKey = NULL;
1209  LSTATUS Result = RegCreateKeyExW(HKEY_CURRENT_USER, s_szRegeditKey, 0,
1210  NULL, 0, KEY_WRITE, NULL, &hKey, NULL);
1211  if (Result != ERROR_SUCCESS)
1212  {
1214  MessageBoxW(hwnd, sz, NULL, MB_ICONERROR);
1215  return;
1216  }
1217 
1218  // set LastKey value
1219  wsprintfW(sz, L"HKEY_LOCAL_MACHINE\\%s", g_pszKey);
1220  DWORD dwSize = sizeof(sz);
1221  Result = RegSetValueExW(hKey, L"LastKey", 0, REG_SZ,
1222  (LPBYTE)sz, dwSize);
1223 
1224  // close now
1225  RegCloseKey(hKey);
1226 
1227  if (Result != ERROR_SUCCESS)
1228  {
1230  MessageBoxW(hwnd, sz, NULL, MB_ICONERROR);
1231  return;
1232  }
1233 
1234  // open by regedit
1235  ShellExecuteW(hwnd, NULL, L"regedit.exe", NULL, NULL, SW_SHOWNORMAL);
1236 }
1237 
1239 {
1240  WCHAR szAbout[MAX_PATH];
1241  LoadStringW(g_hInstance, IDS_ABOUT, szAbout, _countof(szAbout));
1242 
1243  MSGBOXPARAMS Params;
1244  ZeroMemory(&Params, sizeof(Params));
1245  Params.cbSize = sizeof(Params);
1246  Params.hwndOwner = hwnd;
1247  Params.hInstance = g_hInstance;
1248  Params.lpszText = szAbout;
1249  Params.lpszCaption = g_szTitle;
1250  Params.dwStyle = MB_OK | MB_USERICON;
1251  Params.lpszIcon = MAKEINTRESOURCEW(1);
1253  MessageBoxIndirectW(&Params);
1254 }
1255 
1256 void MainWnd_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
1257 {
1258  switch (id)
1259  {
1260  case ID_NEW:
1261  MainWnd_OnNew(hwnd);
1262  break;
1263  case ID_EDIT:
1264  MainWnd_OnEdit(hwnd);
1265  break;
1266  case ID_EXIT:
1267  PostMessage(hwnd, WM_CLOSE, 0, 0);
1268  break;
1269  case ID_RELOAD:
1270  MainWnd_OnReload(hwnd);
1271  break;
1272  case ID_UPDATE_REGISTRY:
1274  break;
1275  case ID_DELETE:
1276  MainWnd_OnDelete(hwnd);
1277  break;
1278  case ID_IMPORT:
1279  MainWnd_OnImport(hwnd);
1280  break;
1281  case ID_EXPORT:
1282  MainWnd_OnExport(hwnd);
1283  break;
1284  case ID_OPEN_REGKEY:
1285  MainWnd_OnOpenRegKey(hwnd);
1286  break;
1287  case ID_ABOUT:
1288  MainWnd_OnAbout(hwnd);
1289  break;
1290  }
1291 }
1292 
1294 {
1295  PostQuitMessage(0);
1296 }
1297 
1299 {
1300  MoveWindow(g_hListView, 0, 0, cx, cy, TRUE);
1301 }
1302 
1303 void MainWnd_OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT *lpDrawItem)
1304 {
1305  if (lpDrawItem->CtlType != ODT_LISTVIEW)
1306  return;
1307 
1308  HDC hDC = lpDrawItem->hDC;
1309  SetBkMode(hDC, TRANSPARENT);
1310 
1311  INT iColumn = 0, x, cx;
1312  RECT rcItem, rcSubItem, rcText;
1313  STRING Str;
1314 
1316 
1317  rcItem = lpDrawItem->rcItem;
1318  if (lpDrawItem->itemState & ODS_SELECTED)
1319  {
1320  FillRect(hDC, &rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1));
1322  }
1323  else
1324  {
1325  FillRect(hDC, &rcItem, (HBRUSH)(COLOR_WINDOW + 1));
1327  }
1328 
1329  cx = ListView_GetColumnWidth(g_hListView, iColumn);
1330  rcSubItem = rcItem;
1331  rcSubItem.left = x;
1332  rcSubItem.right = x + cx;
1333 
1334  WCHAR sz[MAX_STRING];
1335 
1336  rcText = rcSubItem;
1337  InflateRect(&rcText, -1, -1);
1338  Str = g_Items[lpDrawItem->itemID].m_Name;
1339  BYTE CharSet1 = g_Items[lpDrawItem->itemID].m_CharSet1;
1340  if (CharSet1 != DEFAULT_CHARSET)
1341  wsprintfW(sz, L"%s,%u", Str.c_str(), CharSet1);
1342  else
1343  wsprintfW(sz, L"%s", Str.c_str());
1344 
1345  DrawTextW(hDC, sz, lstrlenW(sz), &rcText,
1347  DT_NOPREFIX);
1348 
1349  x += cx;
1350  ++iColumn;
1351 
1352  cx = ListView_GetColumnWidth(g_hListView, iColumn);
1353  rcSubItem = rcItem;
1354  rcSubItem.left = x;
1355  rcSubItem.right = x + cx;
1356 
1357  rcText = rcSubItem;
1358  InflateRect(&rcText, -1, -1);
1359  Str = g_Items[lpDrawItem->itemID].m_Substitute;
1360  BYTE CharSet2 = g_Items[lpDrawItem->itemID].m_CharSet2;
1361  if (CharSet2 != DEFAULT_CHARSET)
1362  wsprintfW(sz, L"%s,%u", Str.c_str(), CharSet2);
1363  else
1364  wsprintfW(sz, L"%s", Str.c_str());
1365 
1366  DrawTextW(hDC, sz, lstrlenW(sz), &rcText,
1368  DT_NOPREFIX);
1369 }
1370 
1372 {
1373  if (lpMeasureItem->CtlType != ODT_LISTVIEW)
1374  return;
1375 
1376  TEXTMETRIC tm;
1377  HDC hDC = GetDC(hwnd);
1378  GetTextMetrics(hDC, &tm);
1379  ReleaseDC(hwnd, hDC);
1380 
1381  lpMeasureItem->itemHeight = tm.tmHeight * 4 / 3;
1382 }
1383 
1384 LRESULT MainWnd_OnNotify(HWND hwnd, int idFrom, NMHDR *pnmhdr)
1385 {
1386  NM_LISTVIEW *pNMLV = (NM_LISTVIEW *)pnmhdr;
1387  LV_KEYDOWN *pLVKD = (LV_KEYDOWN *)pnmhdr;
1388 
1389  switch (pnmhdr->code)
1390  {
1391  case LVN_COLUMNCLICK:
1392  if (pNMLV->iSubItem == g_iSortColumn)
1393  DoSort(pNMLV->iSubItem, !g_bSortAscendant);
1394  else
1395  DoSort(pNMLV->iSubItem, TRUE);
1396  break;
1397  case NM_DBLCLK:
1399  break;
1400  case LVN_KEYDOWN:
1401  if (pLVKD->wVKey == VK_RETURN) // [Enter] key
1402  {
1404  }
1405  if (pLVKD->wVKey == VK_DELETE) // [Del] key
1406  {
1408  }
1409  break;
1410  }
1411  return 0;
1412 }
1413 
1415 {
1416  POINT pt = {(INT)xPos, (INT)yPos};
1419 
1421  if (hMenu == NULL)
1422  return 0;
1423 
1424  HMENU hSubMenu = GetSubMenu(hMenu, 0);
1425  if (hSubMenu == NULL)
1426  return 0;
1427 
1428  SetForegroundWindow(hwnd);
1430  xPos, yPos, 0, g_hMainWnd, NULL);
1431  PostMessage(g_hMainWnd, WM_NULL, 0, 0);
1432  return 0;
1433 }
1434 
1435 void MainWnd_OnActivate(HWND hwnd, UINT state, HWND hwndActDeact, BOOL fMinimized)
1436 {
1437  if (state != WA_INACTIVE)
1438  {
1440  }
1441 }
1442 
1444 {
1445  HANDLE hToken;
1446  LUID luid;
1447  TOKEN_PRIVILEGES tokenPrivileges;
1448  BOOL Ret;
1449 
1452  &hToken);
1453  if (!Ret)
1454  return Ret; // failure
1455 
1456  Ret = ::LookupPrivilegeValueW(NULL, lpPrivilegeName, &luid);
1457  if (Ret)
1458  {
1459  tokenPrivileges.PrivilegeCount = 1;
1460  tokenPrivileges.Privileges[0].Luid = luid;
1461  tokenPrivileges.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
1462 
1463  Ret = ::AdjustTokenPrivileges(hToken, FALSE, &tokenPrivileges, 0, 0, 0);
1464  }
1465 
1466  ::CloseHandle(hToken);
1467  return Ret;
1468 }
1469 
1471 {
1472  if (!g_bNeedsReboot && !g_bModified)
1473  {
1474  DestroyWindow(hwnd);
1475  return;
1476  }
1477 
1478  if (g_bModified)
1479  {
1480  WCHAR szUpdateNow[MAX_STRING];
1481  LoadStringW(g_hInstance, IDS_QUERYUPDATE, szUpdateNow, _countof(szUpdateNow));
1482  INT id = MessageBoxW(hwnd, szUpdateNow, g_szTitle,
1484  switch (id)
1485  {
1486  case IDYES:
1488  break;
1489  case IDNO:
1490  break;
1491  case IDCANCEL:
1492  return;
1493  }
1494  }
1495 
1496  if (g_bNeedsReboot)
1497  {
1498  WCHAR szRebootNow[MAX_STRING];
1499  LoadStringW(g_hInstance, IDS_REBOOTNOW, szRebootNow, _countof(szRebootNow));
1500  INT id = MessageBoxW(hwnd, szRebootNow, g_szTitle,
1502  switch (id)
1503  {
1504  case IDYES:
1507  break;
1508  case IDNO:
1509  break;
1510  case IDCANCEL:
1511  return;
1512  }
1513  }
1514 
1515  ::DestroyWindow(hwnd);
1516 }
1517 
1520 {
1521  switch (uMsg)
1522  {
1533  default:
1534  return DefWindowProc(hwnd, uMsg, wParam, lParam);
1535  }
1536 }
1537 
1540  HINSTANCE hPrevInstance,
1541  LPWSTR lpCmdLine,
1542  INT nCmdShow)
1543 {
1546 
1547  HACCEL hAccel = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(1));
1548 
1552 
1553  WNDCLASSW wc = {0};
1554  wc.style = 0;
1555  wc.lpfnWndProc = WindowProc;
1556  wc.hInstance = hInstance;
1557  g_hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(1));
1558  wc.hIcon = g_hIcon;
1560  wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
1563  if (!RegisterClassW(&wc))
1564  {
1565  MessageBoxA(NULL, "ERROR: RegisterClass failed.", NULL, MB_ICONERROR);
1566  return 1;
1567  }
1568 
1569  const DWORD dwStyle = WS_OVERLAPPEDWINDOW;
1573  INT Height = 320;
1574 
1575  RECT Rect = { 0, 0, Width, Height };
1576  AdjustWindowRect(&Rect, dwStyle, TRUE);
1577  Width = Rect.right - Rect.left;
1578  Height = Rect.bottom - Rect.top;
1579 
1581  CW_USEDEFAULT, CW_USEDEFAULT, Width, Height,
1582  NULL, NULL, hInstance, NULL);
1583  if (g_hMainWnd == NULL)
1584  {
1585  MessageBoxA(NULL, "ERROR: CreateWindow failed.", NULL, MB_ICONERROR);
1586  return 2;
1587  }
1588 
1589  ShowWindow(g_hMainWnd, nCmdShow);
1591 
1592  MSG msg;
1593  while (GetMessage(&msg, NULL, 0, 0))
1594  {
1595  if (TranslateAccelerator(g_hMainWnd, hAccel, &msg))
1596  continue;
1597 
1598  TranslateMessage(&msg);
1599  DispatchMessage(&msg);
1600  }
1601 
1602  return (INT)msg.wParam;
1603 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
std::vector< ITEM > ITEMVECTOR
Definition: fontsub.cpp:68
Definition: fontsub.cpp:35
#define ListView_EnsureVisible(hwndLV, i, fPartialOK)
Definition: commctrl.h:2489
#define WM_NULL
Definition: winuser.h:1579
#define OFN_EXPLORER
Definition: commdlg.h:104
#define LV_ITEM
Definition: commctrl.h:2307
#define HDC
Definition: msvc.h:22
#define ListView_SetColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2599
BOOL g_bNeedsReboot
Definition: fontsub.cpp:51
#define EWX_FORCE
Definition: winuser.h:630
#define TranslateAccelerator
Definition: winuser.h:5705
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2404
DWORD Flags
Definition: commdlg.h:372
void UnescapeChar(const STRING &str, size_t &i, STRING &Ret)
Definition: fontsub.cpp:862
#define DispatchMessage
Definition: winuser.h:5610
BOOL WINAPI TranslateMessage(_In_ const MSG *)
LOGFONTW elfLogFont
Definition: wingdi.h:2668
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define ID_RELOAD
Definition: resource.h:17
void MainWnd_OnExport(HWND hwnd)
Definition: fontsub.cpp:1155
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2198
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
LRESULT MainWnd_OnNotify(HWND hwnd, int idFrom, NMHDR *pnmhdr)
Definition: fontsub.cpp:1384
#define IDS_CANTIMPORT
Definition: resource.h:30
Definition: get.c:139
#define TRUE
Definition: types.h:120
WCHAR g_szSubstituteHead[MAX_STRING]
Definition: fontsub.cpp:59
#define IDOK
Definition: winuser.h:824
#define CloseHandle
Definition: compat.h:398
#define OFN_LONGNAMES
Definition: commdlg.h:108
#define COLOR_HIGHLIGHT
Definition: winuser.h:906
BYTE m_CharSet2
Definition: fontsub.cpp:38
LPCWSTR lpstrFilter
Definition: commdlg.h:362
bool ItemCompareByNameDescend(const ITEM &Item1, const ITEM &Item2)
Definition: fontsub.cpp:165
STRING Escape(const STRING &str)
Definition: fontsub.cpp:1030
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
#define MAC_CHARSET
Definition: wingdi.h:401
#define LVCF_WIDTH
Definition: commctrl.h:2557
#define ID_IMPORT
Definition: resource.h:15
#define HBITMAP
Definition: msvc.h:28
#define LVSIL_SMALL
Definition: commctrl.h:2269
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
bool ItemCompareBySubDescend(const ITEM &Item1, const ITEM &Item2)
Definition: fontsub.cpp:175
long y
Definition: polytest.cpp:48
UINT style
Definition: winuser.h:3119
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define WM_LBUTTONDOWN
Definition: winuser.h:1742
STRING m_Name
Definition: fontsub.cpp:37
#define IDYES
Definition: winuser.h:829
#define ID_EXPORT
Definition: resource.h:17
LPCWSTR lpszMenuName
Definition: winuser.h:3127
LPCWSTR g_pszFileHeader
Definition: fontsub.cpp:55
#define IDS_OUTFILTER
Definition: resource.h:33
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
#define LVCF_TEXT
Definition: commctrl.h:2558
#define EASTEUROPE_CHARSET
Definition: wingdi.h:397
Definition: bidi.c:75
long x
Definition: polytest.cpp:48
const WCHAR g_LongestName[]
Definition: fontsub.cpp:105
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL EditDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
Definition: fontsub.cpp:380
#define IDS_INPFILTER
Definition: resource.h:32
void MainWnd_OnAbout(HWND hwnd)
Definition: fontsub.cpp:1238
#define CB_SETHORIZONTALEXTENT
Definition: winuser.h:1916
#define KEY_READ
Definition: nt_native.h:1023
#define pt(x, y)
Definition: drawing.c:79
#define TPM_LEFTALIGN
Definition: winuser.h:2321
int WINAPI EnumFontFamiliesExW(_In_ HDC, _In_ PLOGFONTW, _In_ FONTENUMPROCW, _In_ LPARAM, _In_ DWORD)
__wchar_t WCHAR
Definition: xmlstorage.h:180
STRING g_strFontName
Definition: fontsub.cpp:72
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define iswxdigit(_c)
Definition: ctype.h:668
LPCWSTR DisplayName
Definition: fontsub.cpp:80
#define LVS_REPORT
Definition: commctrl.h:2232
#define _countof(array)
Definition: fontsub.cpp:30
_STLP_MOVE_TO_STD_NAMESPACE void sort(_RandomAccessIter __first, _RandomAccessIter __last)
Definition: _algo.c:993
#define HKEY_CURRENT_USER
Definition: winreg.h:11
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define LV_COLUMN
Definition: commctrl.h:2517
unsigned char * LPBYTE
Definition: typedefs.h:53
#define SYMBOL_CHARSET
Definition: wingdi.h:383
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define SB_HORZ
Definition: winuser.h:552
#define MAKELPARAM(l, h)
Definition: winuser.h:3894
INT_PTR CALLBACK AddDlg_DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: fontsub.cpp:696
LPCSTR lpszText
Definition: winuser.h:3258
#define IDS_QUERYDELETE
Definition: resource.h:37
LPWSTR lpstrFile
Definition: commdlg.h:366
BYTE lfCharSet
Definition: dimm.idl:67
#define IDS_ENTERNAME
Definition: resource.h:27
void UnescapeHex(const STRING &str, size_t &i, STRING &Ret, BOOL Unicode)
Definition: fontsub.cpp:795
#define LV_KEYDOWN
Definition: commctrl.h:3153
#define CALLBACK
Definition: compat.h:27
#define CHINESEBIG5_CHARSET
Definition: wingdi.h:388
BOOL WINAPI UpdateWindow(_In_ HWND)
static const size_t npos
Definition: _string_npos.h:26
UINT uMsg
Definition: precomp.h:53
#define IDS_IMPORT
Definition: resource.h:28
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2704
LONG top
Definition: windef.h:320
#define IDD_ADD
Definition: resource.h:16
#define ListView_GetItemRect(hwnd, i, prc, code)
Definition: commctrl.h:2448
HANDLE HWND
Definition: compat.h:13
OPENFILENAME ofn
Definition: main.cpp:42
$ULONG PrivilegeCount
Definition: setypes.h:969
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define LVCFMT_LEFT
Definition: commctrl.h:2568
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define ID_OPEN_REGKEY
Definition: resource.h:19
#define assert(x)
Definition: debug.h:53
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define ZeroMemory
Definition: winbase.h:1621
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BYTE g_CharSet1
Definition: fontsub.cpp:74
HWND g_hMainWnd
Definition: fontsub.cpp:47
HWND WINAPI SetFocus(_In_opt_ HWND)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define IDS_EXPORT
Definition: resource.h:29
#define LVNI_SELECTED
Definition: commctrl.h:2394
HICON g_hIcon
Definition: fontsub.cpp:48
void MainWnd_OnDestroy(HWND hwnd)
Definition: fontsub.cpp:1293
GLuint GLuint end
Definition: gl.h:1545
#define WS_CHILD
Definition: pedump.c:617
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define IDS_SUBSTITUTE
Definition: resource.h:26
#define IDS_CANTOPENKEY
Definition: resource.h:38
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2378
LONG left
Definition: windef.h:319
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
INT g_iItem
Definition: fontsub.cpp:52
int32_t INT_PTR
Definition: typedefs.h:63
#define EWX_REBOOT
Definition: winuser.h:633
INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, INT nCmdShow)
Definition: fontsub.cpp:1538
bool ItemCompareByNameAscend(const ITEM &Item1, const ITEM &Item2)
Definition: fontsub.cpp:160
#define GetTextMetrics
Definition: wingdi.h:4451
#define WCHAR
Definition: msvc.h:43
#define DEFAULT_CHARSET
Definition: wingdi.h:382
#define IDS_REBOOTNOW
Definition: resource.h:39
static void trim(STRING &str)
Definition: fontsub.cpp:107
LONG right
Definition: windef.h:321
#define DT_NOPREFIX
Definition: winuser.h:537
#define lstrlenW
Definition: compat.h:407
BOOL WINAPI DestroyWindow(_In_ HWND)
#define MAX_STRING
Definition: fontsub.cpp:27
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4164
#define COLOR_WINDOW
Definition: winuser.h:898
INT g_iSortColumn
Definition: fontsub.cpp:61
int32_t INT
Definition: typedefs.h:57
static BOOLEAN bSuccess
Definition: drive.cpp:429
#define VK_RETURN
Definition: winuser.h:2145
#define CB_GETCURSEL
Definition: winuser.h:1894
DWORD WINAPI GetSysColor(_In_ int)
BOOL AddDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
Definition: fontsub.cpp:554
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
DWORD DWORD
Definition: winlogon.h:75
void MainWnd_OnActivate(HWND hwnd, UINT state, HWND hwndActDeact, BOOL fMinimized)
Definition: fontsub.cpp:1435
static void CharSet(RTF_Info *info)
Definition: reader.c:2410
BOOL WINAPI GetSaveFileNameW(LPOPENFILENAMEW ofn)
Definition: filedlg.c:4090
#define FILE_SHARE_READ
Definition: compat.h:125
#define ODT_LISTVIEW
Definition: commctrl.h:80
DWORD lStructSize
Definition: commdlg.h:359
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1094
BOOL g_bModified
Definition: fontsub.cpp:50
FONTNAMESET g_Names
Definition: fontsub.cpp:70
UINT_PTR WPARAM
Definition: windef.h:230
BOOL DoImport(HWND hwnd, LPCWSTR pszFile)
Definition: fontsub.cpp:997
HINSTANCE hInstance
Definition: winuser.h:3257
void UnescapeOther(const STRING &str, size_t &i, STRING &Ret)
Definition: fontsub.cpp:829
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define IDS_ABOUT
Definition: resource.h:29
#define LVCF_SUBITEM
Definition: commctrl.h:2559
DWORD dwStyle
Definition: winuser.h:3260
int WINAPI MessageBoxA(_In_opt_ HWND, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_ UINT)
UINT code
Definition: winuser.h:3102
WCHAR g_szTitle[MAX_STRING]
Definition: fontsub.cpp:57
#define DialogBox
Definition: winuser.h:5606
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
BOOL WINAPI AdjustWindowRect(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
#define TPM_RIGHTBUTTON
Definition: winuser.h:2324
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
void MainWnd_OnDelete(HWND hwnd)
Definition: fontsub.cpp:1196
GLenum GLclampf GLint i
Definition: glfuncs.h:14
HINSTANCE hInstance
Definition: charmap.c:19
LPCWSTR lpstrDefExt
Definition: commdlg.h:375
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2606
#define COLOR_3DFACE
Definition: winuser.h:909
#define LVN_KEYDOWN
Definition: commctrl.h:3151
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:764
void EditDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
Definition: fontsub.cpp:461
#define FALSE
Definition: types.h:117
#define MB_YESNO
Definition: winuser.h:811
#define UNICODE_NULL
#define DT_LEFT
Definition: winuser.h:534
#define ID_DELETE
Definition: resource.h:25
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2643
HACCEL hAccel
Definition: main.c:47
long LONG
Definition: pedump.c:60
#define CBEIF_TEXT
Definition: commctrl.h:3753
LONG_PTR LPARAM
Definition: windef.h:231
#define MB_USERICON
Definition: winuser.h:777
void AddDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
Definition: fontsub.cpp:611
#define GENERIC_WRITE
Definition: nt_native.h:90
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4025
WNDPROC lpfnWndProc
Definition: winuser.h:3120
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
void MainWnd_OnNew(HWND hwnd)
Definition: fontsub.cpp:706
#define INT(a)
Definition: assyntax.h:463
#define CreateWindowEx
Definition: winuser.h:5600
#define TRANSPARENT
Definition: wingdi.h:948
#define CW_USEDEFAULT
Definition: winuser.h:225
BOOL DoLoadItems(void)
Definition: fontsub.cpp:256
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
HACCEL WINAPI LoadAcceleratorsW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
const WCHAR * str
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2867
#define DT_END_ELLIPSIS
Definition: winuser.h:529
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2274
smooth NULL
Definition: ftsmooth.c:513
#define LVIS_SELECTED
Definition: commctrl.h:2289
#define MB_YESNOCANCEL
Definition: winuser.h:812
LONG cx
Definition: windef.h:347
static const WCHAR szLine[]
Definition: dialog.c:116
LPCWSTR lpszClassName
Definition: winuser.h:3128
#define ListView_DeleteItem(hwnd, i)
Definition: commctrl.h:2381
#define IDS_ALREADYEXISTS
Definition: resource.h:35
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2277
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
void MainWnd_OnClose(HWND hwnd)
Definition: fontsub.cpp:1470
void MainWnd_OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT *lpDrawItem)
Definition: fontsub.cpp:1303
#define TURKISH_CHARSET
Definition: wingdi.h:390
LPCWSTR g_pszClassName
Definition: fontsub.cpp:54
#define ID_ABOUT
Definition: charmap.c:17
void MainWnd_OnSize(HWND hwnd, UINT state, int cx, int cy)
Definition: fontsub.cpp:1298
#define DT_VCENTER
Definition: winuser.h:543
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:907
#define OPEN_EXISTING
Definition: compat.h:426
#define VK_DELETE
Definition: winuser.h:2177
#define CB_ERR
Definition: winuser.h:2379
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: fontsub.cpp:1519
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1581
ITEMVECTOR g_Items
Definition: fontsub.cpp:71
DWORD dwLanguageId
Definition: winuser.h:3264
#define PostMessage
Definition: winuser.h:5677
#define SM_CXSIZEFRAME
Definition: winuser.h:973
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define FILE_FLAG_WRITE_THROUGH
Definition: disk.h:47
#define KEY_WRITE
Definition: nt_native.h:1031
WCHAR g_szNameHead[MAX_STRING]
Definition: fontsub.cpp:58
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4917
LPCWSTR g_pszKey
Definition: fontsub.cpp:64
void LV_InvalidateRow(HWND hwnd, INT iRow=-1)
Definition: fontsub.cpp:315
HDC hDC
Definition: wglext.h:521
Definition: fontsub.cpp:77
#define ComboBox_GetCount(hwndCtl)
Definition: windowsx.h:23
#define IDS_TITLE
Definition: resource.h:30
#define psh1
Definition: dlgs.h:112
unsigned int BOOL
Definition: ntddk_ex.h:94
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
#define TOKEN_QUERY
Definition: setypes.h:874
void LV_OnDelete(HWND hwnd, INT iRow=-1)
Definition: fontsub.cpp:434
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LONG tmHeight
Definition: wingdi.h:2338
std::set< STRING > FONTNAMESET
Definition: fontsub.cpp:67
LPCWSTR lpstrTitle
Definition: commdlg.h:371
#define WM_SIZE
Definition: winuser.h:1583
HANDLE HKEY
Definition: registry.h:24
BOOL DoExport(HWND hwnd, LPCWSTR pszFile)
Definition: fontsub.cpp:1048
UINT WPARAM wParam
Definition: precomp.h:53
#define HANGUL_CHARSET
Definition: wingdi.h:386
#define COLOR_WINDOWTEXT
Definition: winuser.h:901
#define THAI_CHARSET
Definition: wingdi.h:395
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1183
#define ID_EDIT
Definition: resource.h:23
int WINAPI GetScrollPos(_In_ HWND, _In_ int)
#define WM_CLOSE
Definition: winuser.h:1593
HWND hwndOwner
Definition: winuser.h:3256
void DoSort(INT iColumn, BOOL bAscendant=TRUE)
Definition: fontsub.cpp:180
#define MAX_PATH
Definition: compat.h:26
#define RGB(r, g, b)
Definition: wingdi.h:2917
#define SHIFTJIS_CHARSET
Definition: wingdi.h:384
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define LVS_SINGLESEL
Definition: commctrl.h:2236
int WINAPI GetSystemMetrics(_In_ int)
BOOL DoLoad(void)
Definition: fontsub.cpp:310
DWORD nMaxFile
Definition: commdlg.h:367
HICON hIcon
Definition: winuser.h:3124
#define WM_MEASUREITEM
Definition: winuser.h:1618
BOOL Error
Definition: chkdsk.c:63
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:461
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
void MainWnd_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
Definition: fontsub.cpp:1256
#define ListView_SetExtendedListViewStyle(hwndLV, dw)
Definition: commctrl.h:2695
BOOL DoParseFile(LPVOID pvContents, DWORD dwSize)
Definition: fontsub.cpp:915
STRING g_strSubstitute
Definition: fontsub.cpp:73
STRING m_Substitute
Definition: fontsub.cpp:37
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define RUSSIAN_CHARSET
Definition: wingdi.h:394
#define IDS_FONTNAME
Definition: resource.h:11
#define LVS_EX_GRIDLINES
Definition: commctrl.h:2699
#define DEFAULT_GUI_FONT
Definition: wingdi.h:907
#define NM_LISTVIEW
Definition: commctrl.h:3000
std::wstring STRING
Definition: fontsub.cpp:33
#define edt1
Definition: dlgs.h:65
HANDLE HINSTANCE
Definition: typedefs.h:76
_In_ PUNICODE_STRING Name
Definition: mrx.h:218
#define MB_ICONINFORMATION
Definition: winuser.h:796
HWND hwndOwner
Definition: commdlg.h:360
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define OEM_CHARSET
Definition: wingdi.h:398
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
BOOL MainWnd_OnUpdateRegistry(HWND hwnd)
Definition: fontsub.cpp:727
#define IDS_QUERYUPDATE
Definition: resource.h:34
LPWSTR SkipSpace(LPCWSTR pch)
Definition: fontsub.cpp:767
HKEY key
Definition: reg.c:48
#define MB_ICONERROR
Definition: winuser.h:781
LPCSTR lpszIcon
Definition: winuser.h:3261
static int state
Definition: maze.c:121
BOOL MainWnd_OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct)
Definition: fontsub.cpp:531
void MainWnd_OnReload(HWND hwnd)
Definition: fontsub.cpp:1186
void LV_OnDblClk(HWND hwnd)
Definition: fontsub.cpp:515
#define SUB_COLUMN_WIDTH
Definition: fontsub.cpp:26
BYTE m_CharSet1
Definition: fontsub.cpp:38
#define ILC_MASK
Definition: commctrl.h:336
UINTN Column
Definition: acefiex.h:238
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define ID_NEW
Definition: resource.h:21
WCHAR elfFullName[LF_FULLFACESIZE]
Definition: wingdi.h:2669
#define GB2312_CHARSET
Definition: wingdi.h:387
ITEM(const STRING &Name, const STRING &Substitute, BYTE CharSet1, BYTE CharSet2)
Definition: fontsub.cpp:39
BOOL EnableProcessPrivileges(LPCWSTR lpPrivilegeName, BOOL bEnable=TRUE)
Definition: fontsub.cpp:1443
#define GENERIC_READ
Definition: compat.h:124
#define CB_SETCURSEL
Definition: winuser.h:1912
Definition: time.h:76
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1706
#define LR_LOADMAP3DCOLORS
Definition: winuser.h:1077
_In_ HANDLE hFile
Definition: mswsock.h:90
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
GLsizei const GLfloat * value
Definition: glext.h:6069
#define WINAPI
Definition: msvc.h:20
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
#define LoadCursor
Definition: winuser.h:5657
void MainWnd_OnImport(HWND hwnd)
Definition: fontsub.cpp:1123
#define ID_EXIT
Definition: resource.h:10
#define OPENFILENAME_SIZE_VERSION_400
Definition: commdlg.h:401
BOOL DoLoadNames(void)
Definition: fontsub.cpp:145
unsigned char BYTE
Definition: ntddk_ex.h:96
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:366
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HCURSOR hCursor
Definition: winuser.h:3125
void LV_AddItems(HWND hwnd)
Definition: fontsub.cpp:233
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:756
#define cmb2
Definition: dlgs.h:49
#define DT_SINGLELINE
Definition: winuser.h:540
INT_PTR CALLBACK EditDlg_DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: fontsub.cpp:505
#define LVCF_FMT
Definition: commctrl.h:2556
#define CREATE_ALWAYS
Definition: disk.h:72
#define LVIR_BOUNDS
Definition: commctrl.h:2442
#define SW_SHOWNORMAL
Definition: winuser.h:764
DWORD *typedef HANDLE
Definition: winlogon.h:52
_In_ BOOL bEnable
Definition: winddi.h:3426
#define OFN_DONTADDTORECENT
Definition: commdlg.h:98
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define WM_ACTIVATE
Definition: winuser.h:1584
#define LoadMenu
Definition: winuser.h:5662
#define NM_DBLCLK
Definition: commctrl.h:131
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2368
BOOL WINAPI DeleteDC(_In_ HDC)
STRING Unquote(const STRING &str)
Definition: fontsub.cpp:898
#define CB_SETEDITSEL
Definition: winuser.h:1914
#define FILE_FLAG_SEQUENTIAL_SCAN
Definition: disk.h:43
#define VIETNAMESE_CHARSET
Definition: wingdi.h:400
FARPROC FONTENUMPROCW
Definition: wingdi.h:2874
LRESULT MainWnd_OnContextMenu(HWND hwnd, HWND hwndContext, UINT xPos, UINT yPos)
Definition: fontsub.cpp:1414
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define HEBREW_CHARSET
Definition: wingdi.h:391
HBRUSH hbrBackground
Definition: winuser.h:3126
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define LR_CREATEDIBSECTION
Definition: winuser.h:1078
#define cmb3
Definition: dlgs.h:50
#define IDS_CANTEXPORT
Definition: resource.h:31
UINT WPARAM LPARAM lParam
Definition: precomp.h:53
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:286
#define WS_VSCROLL
Definition: pedump.c:627
#define MB_OK
Definition: winuser.h:784
#define IMAGE_BITMAP
Definition: winuser.h:211
#define GetMessage
Definition: winuser.h:5635
#define SM_CXVSCROLL
Definition: winuser.h:941
#define LVN_COLUMNCLICK
Definition: commctrl.h:3109
#define IDS_ENTERNAME2
Definition: resource.h:36
#define ID_UPDATE_REGISTRY
Definition: resource.h:13
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:970
#define ARABIC_CHARSET
Definition: wingdi.h:392
#define CreateFileW
Definition: compat.h:400
#define WM_DRAWITEM
Definition: winuser.h:1617
HINSTANCE hInstance
Definition: winuser.h:3123
#define WC_LISTVIEW
Definition: commctrl.h:2229
#define msg(x)
Definition: auth_time.c:54
BYTE g_CharSet2
Definition: fontsub.cpp:75
#define IDC_ARROW
Definition: winuser.h:682
_Out_opt_ int * cx
Definition: commctrl.h:570
static const WCHAR szName[]
Definition: msipriv.h:1212
LPWSTR SkipQuoted(LPWSTR pch)
Definition: fontsub.cpp:776
#define ODS_SELECTED
Definition: winuser.h:2489
#define IDD_EDIT
Definition: resource.h:22
#define LVIF_PARAM
Definition: commctrl.h:2281
#define WM_CREATE
Definition: winuser.h:1580
void MainWnd_OnOpenRegKey(HWND hwnd)
Definition: fontsub.cpp:1201
int WINAPI MessageBoxIndirectW(_In_ CONST MSGBOXPARAMSW *)
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2230
static int CALLBACK EnumFontFamExProc(const ENUMLOGFONTW *pelf, const NEWTEXTMETRICW *pntm, int FontType, LPARAM lParam)
Definition: fontsub.cpp:123
#define cmb4
Definition: dlgs.h:51
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
#define SE_SHUTDOWN_NAME
Definition: winnt_old.h:372
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define ILC_COLOR8
Definition: commctrl.h:340
BOOL LV_Init(HWND hwnd)
Definition: fontsub.cpp:328
BOOL WINAPI SetForegroundWindow(_In_ HWND)
void MainWnd_OnMeasureItem(HWND hwnd, MEASUREITEMSTRUCT *lpMeasureItem)
Definition: fontsub.cpp:1371
LONG bottom
Definition: windef.h:322
#define LV_COLUMNW
Definition: commctrl.h:2516
struct CHARSET_ENTRY CHARSET_ENTRY
#define LoadImage
Definition: winuser.h:5660
#define HANDLE_MSG(hwnd, message, fn)
Definition: windowsx.h:297
WCHAR * pch
Definition: msvc.h:81
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:523
#define LVCF_IMAGE
Definition: commctrl.h:2560
#define WA_INACTIVE
Definition: winuser.h:2566
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:865
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
BOOL g_bSortAscendant
Definition: fontsub.cpp:62
#define LoadIcon
Definition: winuser.h:5658
#define IDNO
Definition: winuser.h:830
#define ANSI_CHARSET
Definition: wingdi.h:381
#define IDCANCEL
Definition: winuser.h:825
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
#define JOHAB_CHARSET
Definition: wingdi.h:399
LONG_PTR LRESULT
Definition: windef.h:232
void MainWnd_OnEdit(HWND hwnd)
Definition: fontsub.cpp:1191
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define BALTIC_CHARSET
Definition: wingdi.h:393
#define OFN_ENABLESIZING
Definition: commdlg.h:101
#define GREEK_CHARSET
Definition: wingdi.h:389
#define WS_VISIBLE
Definition: pedump.c:620
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:876
#define cmb1
Definition: dlgs.h:48
HWND g_hListView
Definition: fontsub.cpp:49
bool ItemCompareBySubAscend(const ITEM &Item1, const ITEM &Item2)
Definition: fontsub.cpp:170
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:68
#define CBEM_INSERTITEM
Definition: commctrl.h:3812
#define WM_INITDIALOG
Definition: winuser.h:1705
#define ListView_GetColumnWidth(hwnd, iCol)
Definition: commctrl.h:2612
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
CHARSET_ENTRY g_CharSetList[]
Definition: fontsub.cpp:83
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
void MakeFilter(LPWSTR pszFilter)
Definition: fontsub.cpp:1112
#define LVS_OWNERDRAWFIXED
Definition: commctrl.h:2253
#define LVIS_FOCUSED
Definition: commctrl.h:2288
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
#define WM_NOTIFY
Definition: richedit.h:61
struct Rect Rect
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50
LPCSTR lpszCaption
Definition: winuser.h:3259
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2384
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17
Definition: path.c:42
static VOID Substitute(_Out_writes_bytes_(BufferSize) PWCHAR Buffer, _In_ ULONG BufferSize, _In_ PCWSTR Template, _In_ PCWSTR SystemDriveName, _In_ PCWSTR SystemRootName)
Definition: IoFilesystem.c:220
BYTE CharSet
Definition: fontsub.cpp:79
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define NAME_COLUMN_WIDTH
Definition: fontsub.cpp:25
INT x
Definition: msvc.h:62
#define REG_SZ
Definition: layer.c:33
DWORD dwSize
Definition: wglext.h:734