Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

769 lines
37 KiB

  1. #include "private.h"
  2. //
  3. // CLSID for MLANG objects
  4. //
  5. typedef struct tagCLSIDOBJ
  6. {
  7. LPCTSTR szCLSID;
  8. LPCTSTR szDesc;
  9. } CLSIDOBJ, *LPCLSIDOBJ;
  10. const CLSIDOBJ clsidObj[] =
  11. {
  12. { TEXT("CLSID\\{275C23E2-3747-11D0-9FEA-00AA003F8646}"), TEXT("Multi Language Support") }, // CLSID_MLANG
  13. { TEXT("CLSID\\{C04D65CF-B70D-11D0-B188-00AA0038C969}"), TEXT("Multi Language String") }, // CLSID_MLANG
  14. { TEXT("CLSID\\{D66D6F99-CDAA-11D0-B822-00C04FC9B31F}"), TEXT("Multi Language ConvertCharset") }, // CLSID_MLANG
  15. { NULL, NULL }
  16. };
  17. LPCTSTR szInProcServer = TEXT("InProcServer32");
  18. LPCTSTR szThreadingModel = TEXT("ThreadingModel");
  19. LPCTSTR szThreadingModelValue = TEXT("Both");
  20. HRESULT RegisterServerInfo(void)
  21. {
  22. HKEY hKey = NULL, hKeySub = NULL;
  23. DWORD dwAction = 0;
  24. int i = 0;
  25. TCHAR szModule[MAX_PATH];
  26. HRESULT hr = S_OK;
  27. if (!GetModuleFileName(g_hInst, szModule, ARRAYSIZE(szModule)))
  28. hr = E_FAIL;
  29. while (SUCCEEDED(hr) && clsidObj[i].szCLSID)
  30. {
  31. if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_CLASSES_ROOT, clsidObj[i].szCLSID, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwAction))
  32. {
  33. ASSERT(NULL != hKey);
  34. if (ERROR_SUCCESS != RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)clsidObj[i].szDesc, (lstrlen(clsidObj[i].szDesc) + 1) * sizeof(TCHAR)))
  35. hr = E_FAIL;
  36. if (ERROR_SUCCESS == RegCreateKeyEx(hKey, szInProcServer, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKeySub, &dwAction))
  37. {
  38. ASSERT(NULL != hKeySub);
  39. if (ERROR_SUCCESS != RegSetValueEx(hKeySub, NULL, 0, REG_SZ, (LPBYTE)szModule, (lstrlen(szModule) + 1) * sizeof(TCHAR)))
  40. hr = E_FAIL;
  41. if (ERROR_SUCCESS != RegSetValueEx(hKeySub, szThreadingModel, 0, REG_SZ, (LPBYTE)szThreadingModelValue, (lstrlen(szThreadingModelValue) + 1) * sizeof(TCHAR)))
  42. hr = E_FAIL;
  43. RegCloseKey(hKeySub);
  44. hKeySub = NULL;
  45. }
  46. else
  47. hr = E_FAIL;
  48. RegCloseKey(hKey);
  49. hKey = NULL;
  50. }
  51. else
  52. hr = E_FAIL;
  53. i++;
  54. }
  55. return hr;
  56. }
  57. HRESULT UnregisterServerInfo(void)
  58. {
  59. HKEY hKey = NULL;
  60. int i = 0;
  61. HRESULT hr = S_OK;
  62. while (clsidObj[i].szCLSID)
  63. {
  64. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, clsidObj[i].szCLSID, 0, KEY_ALL_ACCESS, &hKey))
  65. {
  66. ASSERT(NULL != hKey);
  67. if (ERROR_SUCCESS != RegDeleteKey(hKey, szInProcServer))
  68. hr = E_FAIL;
  69. RegCloseKey(hKey);
  70. hKey = NULL;
  71. if (ERROR_SUCCESS != RegDeleteKey(HKEY_CLASSES_ROOT, clsidObj[i].szCLSID))
  72. hr = E_FAIL;
  73. }
  74. else
  75. hr = S_FALSE;
  76. i++;
  77. }
  78. return hr;
  79. }
  80. // Legacy code for Outlook Express and other clients who depend on MLang created MIME DB in registry
  81. // Those client should switch to MLang interface for MIME data
  82. long PrivRegSetValueEx(HKEY hKey, LPCTSTR lpValueName, DWORD dwType, CONST BYTE *lpData, DWORD cbData, BOOL bOverWrite)
  83. {
  84. long lRet = ERROR_SUCCESS;
  85. if (bOverWrite || ERROR_SUCCESS != RegQueryValueEx(hKey, lpValueName, 0, NULL, NULL, NULL))
  86. lRet = RegSetValueEx(hKey, lpValueName, 0, dwType, lpData, cbData);
  87. return lRet;
  88. }
  89. //
  90. // MIME database Key or Value name
  91. //
  92. LPCTSTR szMIMEDatabase = TEXT("MIME\\Database");
  93. LPCTSTR szCharset = TEXT("Charset");
  94. LPCTSTR szRfc1766 = TEXT("Rfc1766");
  95. LPCTSTR szCodepage = TEXT("Codepage");
  96. LPCTSTR szInternetEncoding = TEXT("InternetEncoding");
  97. LPCTSTR szAliasForCharset = TEXT("AliasForCharset");
  98. LPCTSTR szHeaderCharset = TEXT("HeaderCharset");
  99. LPCTSTR szBodyCharset = TEXT("BodyCharset");
  100. LPCTSTR szWebCharset = TEXT("WebCharset");
  101. LPCTSTR szFixedWidthFont = TEXT("FixedWidthFont");
  102. LPCTSTR szProportionalFont = TEXT("ProportionalFont");
  103. LPCTSTR szDescription = TEXT("Description");
  104. LPCTSTR szFamily = TEXT("Family");
  105. LPCTSTR szLevel = TEXT("Level");
  106. LPCTSTR szEncoding = TEXT("Encoding");
  107. //
  108. // RFC1766 registry data at MIME\Database
  109. //
  110. typedef struct tagREGRFC1766
  111. {
  112. LPCTSTR szLCID;
  113. LPCTSTR szAcceptLang;
  114. UINT uidLCID;
  115. } REGRFC1766, *LPREGRFC1766;
  116. const REGRFC1766 regRfc1766[] =
  117. {
  118. { TEXT("0436"), TEXT("af"), IDS_RFC1766_LCID0436 },
  119. { TEXT("041C"), TEXT("sq"), IDS_RFC1766_LCID041C },
  120. { TEXT("0001"), TEXT("ar"), IDS_RFC1766_LCID0001 },
  121. { TEXT("0401"), TEXT("ar-sa"), IDS_RFC1766_LCID0401 },
  122. { TEXT("0801"), TEXT("ar-iq"), IDS_RFC1766_LCID0801 },
  123. { TEXT("0C01"), TEXT("ar-eg"), IDS_RFC1766_LCID0C01 },
  124. { TEXT("1001"), TEXT("ar-ly"), IDS_RFC1766_LCID1001 },
  125. { TEXT("1401"), TEXT("ar-dz"), IDS_RFC1766_LCID1401 },
  126. { TEXT("1801"), TEXT("ar-ma"), IDS_RFC1766_LCID1801 },
  127. { TEXT("1C01"), TEXT("ar-tn"), IDS_RFC1766_LCID1C01 },
  128. { TEXT("2001"), TEXT("ar-om"), IDS_RFC1766_LCID2001 },
  129. { TEXT("2401"), TEXT("ar-ye"), IDS_RFC1766_LCID2401 },
  130. { TEXT("2801"), TEXT("ar-sy"), IDS_RFC1766_LCID2801 },
  131. { TEXT("2C01"), TEXT("ar-jo"), IDS_RFC1766_LCID2C01 },
  132. { TEXT("3001"), TEXT("ar-lb"), IDS_RFC1766_LCID3001 },
  133. { TEXT("3401"), TEXT("ar-kw"), IDS_RFC1766_LCID3401 },
  134. { TEXT("3801"), TEXT("ar-ae"), IDS_RFC1766_LCID3801 },
  135. { TEXT("3C01"), TEXT("ar-bh"), IDS_RFC1766_LCID3C01 },
  136. { TEXT("4001"), TEXT("ar-qa"), IDS_RFC1766_LCID4001 },
  137. { TEXT("042D"), TEXT("eu"), IDS_RFC1766_LCID042D },
  138. { TEXT("0402"), TEXT("bg"), IDS_RFC1766_LCID0402 },
  139. { TEXT("0423"), TEXT("be"), IDS_RFC1766_LCID0423 },
  140. { TEXT("0403"), TEXT("ca"), IDS_RFC1766_LCID0403 },
  141. { TEXT("0004"), TEXT("zh"), IDS_RFC1766_LCID0004 },
  142. { TEXT("0404"), TEXT("zh-tw"), IDS_RFC1766_LCID0404 },
  143. { TEXT("0804"), TEXT("zh-cn"), IDS_RFC1766_LCID0804 },
  144. { TEXT("0C04"), TEXT("zh-hk"), IDS_RFC1766_LCID0C04 },
  145. { TEXT("1004"), TEXT("zh-sg"), IDS_RFC1766_LCID1004 },
  146. { TEXT("041A"), TEXT("hr"), IDS_RFC1766_LCID041A },
  147. { TEXT("0405"), TEXT("cs"), IDS_RFC1766_LCID0405 },
  148. { TEXT("0406"), TEXT("da"), IDS_RFC1766_LCID0406 },
  149. { TEXT("0413"), TEXT("nl"), IDS_RFC1766_LCID0413 },
  150. { TEXT("0813"), TEXT("nl-be"), IDS_RFC1766_LCID0813 },
  151. { TEXT("0009"), TEXT("en"), IDS_RFC1766_LCID0009 },
  152. { TEXT("0409"), TEXT("en-us"), IDS_RFC1766_LCID0409 },
  153. { TEXT("0809"), TEXT("en-gb"), IDS_RFC1766_LCID0809 },
  154. { TEXT("0C09"), TEXT("en-au"), IDS_RFC1766_LCID0C09 },
  155. { TEXT("1009"), TEXT("en-ca"), IDS_RFC1766_LCID1009 },
  156. { TEXT("1409"), TEXT("en-nz"), IDS_RFC1766_LCID1409 },
  157. { TEXT("1809"), TEXT("en-ie"), IDS_RFC1766_LCID1809 },
  158. { TEXT("1C09"), TEXT("en-za"), IDS_RFC1766_LCID1C09 },
  159. { TEXT("2009"), TEXT("en-jm"), IDS_RFC1766_LCID2009 },
  160. { TEXT("2809"), TEXT("en-bz"), IDS_RFC1766_LCID2809 },
  161. { TEXT("2C09"), TEXT("en-tt"), IDS_RFC1766_LCID2C09 },
  162. { TEXT("0425"), TEXT("et"), IDS_RFC1766_LCID0425 },
  163. { TEXT("0438"), TEXT("fo"), IDS_RFC1766_LCID0438 },
  164. { TEXT("0429"), TEXT("fa"), IDS_RFC1766_LCID0429 },
  165. { TEXT("040B"), TEXT("fi"), IDS_RFC1766_LCID040B },
  166. { TEXT("040C"), TEXT("fr"), IDS_RFC1766_LCID040C },
  167. { TEXT("080C"), TEXT("fr-be"), IDS_RFC1766_LCID080C },
  168. { TEXT("0C0C"), TEXT("fr-ca"), IDS_RFC1766_LCID0C0C },
  169. { TEXT("100C"), TEXT("fr-ch"), IDS_RFC1766_LCID100C },
  170. { TEXT("140C"), TEXT("fr-lu"), IDS_RFC1766_LCID140C },
  171. { TEXT("043C"), TEXT("gd"), IDS_RFC1766_LCID043C },
  172. { TEXT("0407"), TEXT("de"), IDS_RFC1766_LCID0407 },
  173. { TEXT("0807"), TEXT("de-ch"), IDS_RFC1766_LCID0807 },
  174. { TEXT("0C07"), TEXT("de-at"), IDS_RFC1766_LCID0C07 },
  175. { TEXT("1007"), TEXT("de-lu"), IDS_RFC1766_LCID1007 },
  176. { TEXT("1407"), TEXT("de-li"), IDS_RFC1766_LCID1407 },
  177. { TEXT("0408"), TEXT("el"), IDS_RFC1766_LCID0408 },
  178. { TEXT("040D"), TEXT("he"), IDS_RFC1766_LCID040D },
  179. { TEXT("0439"), TEXT("hi"), IDS_RFC1766_LCID0439 },
  180. { TEXT("040E"), TEXT("hu"), IDS_RFC1766_LCID040E },
  181. { TEXT("040F"), TEXT("is"), IDS_RFC1766_LCID040F },
  182. { TEXT("0421"), TEXT("in"), IDS_RFC1766_LCID0421 },
  183. { TEXT("0410"), TEXT("it"), IDS_RFC1766_LCID0410 },
  184. { TEXT("0810"), TEXT("it-ch"), IDS_RFC1766_LCID0810 },
  185. { TEXT("0411"), TEXT("ja"), IDS_RFC1766_LCID0411 },
  186. { TEXT("0412"), TEXT("ko"), IDS_RFC1766_LCID0412 },
  187. { TEXT("0426"), TEXT("lv"), IDS_RFC1766_LCID0426 },
  188. { TEXT("0427"), TEXT("lt"), IDS_RFC1766_LCID0427 },
  189. { TEXT("042F"), TEXT("mk"), IDS_RFC1766_LCID042F },
  190. { TEXT("043E"), TEXT("ms"), IDS_RFC1766_LCID043E },
  191. { TEXT("043A"), TEXT("mt"), IDS_RFC1766_LCID043A },
  192. { TEXT("0414"), TEXT("no"), IDS_RFC1766_LCID0414 },
  193. { TEXT("0814"), TEXT("no"), IDS_RFC1766_LCID0814 },
  194. { TEXT("0415"), TEXT("pl"), IDS_RFC1766_LCID0415 },
  195. { TEXT("0416"), TEXT("pt-br"), IDS_RFC1766_LCID0416 },
  196. { TEXT("0816"), TEXT("pt"), IDS_RFC1766_LCID0816 },
  197. { TEXT("0417"), TEXT("rm"), IDS_RFC1766_LCID0417 },
  198. { TEXT("0418"), TEXT("ro"), IDS_RFC1766_LCID0418 },
  199. { TEXT("0818"), TEXT("ro-mo"), IDS_RFC1766_LCID0818 },
  200. { TEXT("0419"), TEXT("ru"), IDS_RFC1766_LCID0419 },
  201. { TEXT("0819"), TEXT("ru-mo"), IDS_RFC1766_LCID0819 },
  202. { TEXT("0C1A"), TEXT("sr"), IDS_RFC1766_LCID0C1A },
  203. { TEXT("081A"), TEXT("sr"), IDS_RFC1766_LCID081A },
  204. { TEXT("041B"), TEXT("sk"), IDS_RFC1766_LCID041B },
  205. { TEXT("0424"), TEXT("sl"), IDS_RFC1766_LCID0424 },
  206. { TEXT("042E"), TEXT("sb"), IDS_RFC1766_LCID042E },
  207. { TEXT("040A"), TEXT("es"), IDS_RFC1766_LCID040A },
  208. { TEXT("080A"), TEXT("es-mx"), IDS_RFC1766_LCID080A },
  209. { TEXT("0C0A"), TEXT("es"), IDS_RFC1766_LCID0C0A },
  210. { TEXT("100A"), TEXT("es-gt"), IDS_RFC1766_LCID100A },
  211. { TEXT("140A"), TEXT("es-cr"), IDS_RFC1766_LCID140A },
  212. { TEXT("180A"), TEXT("es-pa"), IDS_RFC1766_LCID180A },
  213. { TEXT("1C0A"), TEXT("es-do"), IDS_RFC1766_LCID1C0A },
  214. { TEXT("200A"), TEXT("es-ve"), IDS_RFC1766_LCID200A },
  215. { TEXT("240A"), TEXT("es-co"), IDS_RFC1766_LCID240A },
  216. { TEXT("280A"), TEXT("es-pe"), IDS_RFC1766_LCID280A },
  217. { TEXT("2C0A"), TEXT("es-ar"), IDS_RFC1766_LCID2C0A },
  218. { TEXT("300A"), TEXT("es-ec"), IDS_RFC1766_LCID300A },
  219. { TEXT("340A"), TEXT("es-cl"), IDS_RFC1766_LCID340A },
  220. { TEXT("380A"), TEXT("es-uy"), IDS_RFC1766_LCID380A },
  221. { TEXT("3C0A"), TEXT("es-py"), IDS_RFC1766_LCID3C0A },
  222. { TEXT("400A"), TEXT("es-bo"), IDS_RFC1766_LCID400A },
  223. { TEXT("440A"), TEXT("es-sv"), IDS_RFC1766_LCID440A },
  224. { TEXT("480A"), TEXT("es-hn"), IDS_RFC1766_LCID480A },
  225. { TEXT("4C0A"), TEXT("es-ni"), IDS_RFC1766_LCID4C0A },
  226. { TEXT("500A"), TEXT("es-pr"), IDS_RFC1766_LCID500A },
  227. { TEXT("0430"), TEXT("sx"), IDS_RFC1766_LCID0430 },
  228. { TEXT("041D"), TEXT("sv"), IDS_RFC1766_LCID041D },
  229. { TEXT("081D"), TEXT("sv-fi"), IDS_RFC1766_LCID081D },
  230. { TEXT("041E"), TEXT("th"), IDS_RFC1766_LCID041E },
  231. { TEXT("0431"), TEXT("ts"), IDS_RFC1766_LCID0431 },
  232. { TEXT("0432"), TEXT("tn"), IDS_RFC1766_LCID0432 },
  233. { TEXT("041F"), TEXT("tr"), IDS_RFC1766_LCID041F },
  234. { TEXT("0422"), TEXT("uk"), IDS_RFC1766_LCID0422 },
  235. { TEXT("0420"), TEXT("ur"), IDS_RFC1766_LCID0420 },
  236. { TEXT("042A"), TEXT("vi"), IDS_RFC1766_LCID042A },
  237. { TEXT("0434"), TEXT("xh"), IDS_RFC1766_LCID0434 },
  238. { TEXT("043D"), TEXT("ji"), IDS_RFC1766_LCID043D },
  239. { TEXT("0435"), TEXT("zu"), IDS_RFC1766_LCID0435 },
  240. { NULL, NULL, 0 }
  241. };
  242. //
  243. // Charset registry data at MIME\Database
  244. //
  245. typedef struct tagREGCHARSET
  246. {
  247. LPCTSTR szCharset;
  248. DWORD dwCodePage;
  249. DWORD dwInternetEncoding;
  250. LPCTSTR szAliasForCharset;
  251. DWORD dwCharsetMask;
  252. } REGCHARSET, *LPREGCHARSET;
  253. const REGCHARSET regCharset[] =
  254. {
  255. { TEXT("_autodetect_all"), 50001, 50001, NULL, 0x0 },
  256. { TEXT("_autodetect"), 50932, 50932, NULL, 0x0 },
  257. { TEXT("_autodetect_kr"), 50949, 50949, NULL, 0x0 },
  258. { TEXT("_iso-2022-jp$ESC"), 932, 50221, NULL, 0x0 },
  259. { TEXT("_iso-2022-jp$SIO"), 932, 50222, NULL, 0x3 },
  260. { TEXT("Big5"), 950, 950, NULL, 0x0 },
  261. { TEXT("ks_c_5601-1987"), 949, 949, NULL, 0x3 },
  262. { TEXT("euc-kr"), 949, 949, NULL, 0x3 },
  263. { TEXT("GB2312"), 936, 936, NULL, 0x0 },
  264. { TEXT("hz-gb-2312"), 936, 52936, NULL, 0x0 },
  265. { TEXT("ibm852"), 852, 852, NULL, 0x3 },
  266. { TEXT("ibm866"), 866, 866, NULL, 0x3 },
  267. { TEXT("iso-2022-jp"), 932, 50220, NULL,0x3 },
  268. { TEXT("iso-2022-kr"), 949, 50225, NULL, 0x3 },
  269. { TEXT("iso-8859-1"), 1252, 1252, NULL, 0x0 },
  270. { TEXT("iso-8859-2"), 1250, 28592, NULL, 0x0 },
  271. { TEXT("iso-8859-3"), 1254, 28593, NULL, 0x0 },
  272. { TEXT("iso-8859-4"), 1257, 28594, NULL, 0x0 },
  273. { TEXT("iso-8859-5"), 1251, 28595, NULL, 0x0 },
  274. { TEXT("iso-8859-6"), 1256, 28596, NULL, 0x0 },
  275. { TEXT("iso-8859-7"), 1253, 28597, NULL, 0x0 },
  276. { TEXT("iso-8859-8"), 1255, 28598, NULL, 0x2 },
  277. { TEXT("iso-8859-8-i"), 1255, 38598, NULL, 0x0 },
  278. { TEXT("iso-8859-9"), 1254, 1254, NULL, 0x0 },
  279. { TEXT("iso-8859-11"), 0, 0, TEXT("windows-874"), 0x0 },
  280. { TEXT("koi8-r"), 1251, 20866, NULL, 0x0 },
  281. { TEXT("koi8-ru"), 1251, 21866, NULL, 0x2 },
  282. { TEXT("shift_jis"), 932, 932, NULL, 0x0 },
  283. { TEXT("unicode-1-1-utf-7"), 0, 0, TEXT("utf-7"), 0x4 },
  284. { TEXT("unicode-1-1-utf-8"), 0, 0, TEXT("utf-8"), 0x0 },
  285. { TEXT("x-unicode-2-0-utf-7"), 0, 0, TEXT("utf-7"), 0x4 },
  286. { TEXT("x-unicode-2-0-utf-8"), 0, 0, TEXT("utf-8"), 0x4 },
  287. { TEXT("utf-7"), 1200, 65000, NULL, 0x1 },
  288. { TEXT("utf-8"), 1200, 65001, NULL, 0x1 },
  289. { TEXT("unicode"), 1200, 1200, NULL, 0x0 },
  290. { TEXT("unicodeFFFE"), 1200, 1201, NULL, 0x0 },
  291. { TEXT("windows-1250"), 1250, 1250, NULL, 0x0 },
  292. { TEXT("windows-1251"), 1251, 1251, NULL, 0x0 },
  293. { TEXT("windows-1252"), 1252, 1252, NULL, 0x0 },
  294. { TEXT("windows-1253"), 1253, 1253, NULL, 0x0 },
  295. { TEXT("windows-1255"), 1255, 1255, NULL, 0x0 },
  296. { TEXT("windows-1256"), 1256, 1256, NULL, 0x0 },
  297. { TEXT("windows-1257"), 1257, 1257, NULL, 0x0 },
  298. { TEXT("windows-1258"), 1258, 1258, NULL, 0x0 },
  299. { TEXT("windows-874"), 874, 874, NULL, 0x0 },
  300. { TEXT("x-user-defined"), 50000, 50000, NULL, 0x0 },
  301. { TEXT("x-ansi"), 0, 0, TEXT("windows-1252"), 0x0 },
  302. { TEXT("euc-jp"), 932, 51932, NULL, 0x0 },
  303. { TEXT("x-euc-jp"), 0, 0, TEXT("euc-jp"), 0x0 },
  304. { TEXT("x-euc"), 0, 0, TEXT("euc-jp"), 0x0 },
  305. { TEXT("x-ms-cp932"), 0, 0, TEXT("shift_jis"), 0x0 },
  306. { TEXT("x-sjis"), 0, 0, TEXT("shift_jis"), 0x0 },
  307. { TEXT("ANSI_X3.4-1968"), 0, 0, TEXT("iso-8859-1"), 0x4 },
  308. { TEXT("ANSI_X3.4-1986"), 0, 0, TEXT("iso-8859-1"), 0x4 },
  309. { TEXT("ascii"), 0, 0, TEXT("iso-8859-1"), 0x0 },
  310. { TEXT("chinese"), 0, 0, TEXT("gb2312"), 0x0 },
  311. { TEXT("CN-GB"), 0, 0, TEXT("gb2312"), 0x0 },
  312. { TEXT("cp866"), 0, 0, TEXT("ibm866"), 0x0 },
  313. { TEXT("cp852"), 0, 0, TEXT("ibm852"), 0x0 },
  314. { TEXT("cp367"), 0, 0, TEXT("iso-8859-1"), 0x4 },
  315. { TEXT("cp819"), 0, 0, TEXT("iso-8859-1"), 0x4 },
  316. { TEXT("csASCII"), 0, 0, TEXT("iso-8859-1"), 0x0 },
  317. { TEXT("csbig5"), 0, 0, TEXT("big5"), 0x0 },
  318. { TEXT("csEUCPkdFmtJapanese"), 0, 0, TEXT("euc-jp"), 0x0 },
  319. { TEXT("csGB2312"), 0, 0, TEXT("gb2312"), 0x0 },
  320. { TEXT("csISO2022KR"), 0, 0, TEXT("iso-2022-kr"), 0x0 },
  321. { TEXT("csISO58GB231280"), 0, 0, TEXT("gb2312"), 0x0 },
  322. { TEXT("csISOLatin2"), 0, 0, TEXT("iso-8859-2"), 0x0 },
  323. { TEXT("csISOLatin4"), 0, 0, TEXT("iso-8859-4"), 0x0 },
  324. { TEXT("csISOLatin5"), 0, 0, TEXT("iso-8859-9"), 0x4 },
  325. { TEXT("csISOLatinCyrillic"), 0, 0, TEXT("iso-8859-5"), 0x0 },
  326. { TEXT("csISOLatinGreek"), 0, 0, TEXT("iso-8859-7"), 0x0 },
  327. { TEXT("csISOLatinHebrew"), 0, 0, TEXT("iso-8859-8"), 0x0 },
  328. { TEXT("csKSC56011987"), 0, 0, TEXT("ks_c_5601-1987"), 0x0 },
  329. { TEXT("csShiftJIS"), 0, 0, TEXT("shift_jis"), 0x0 },
  330. { TEXT("csUnicode11UTF7"), 0, 0, TEXT("utf-7"), 0x0 },
  331. { TEXT("csWindows31J"), 0, 0, TEXT("shift_jis"), 0x0 },
  332. { TEXT("cyrillic"), 0, 0, TEXT("iso-8859-5"), 0x0 },
  333. { TEXT("ECMA-118"), 0, 0, TEXT("iso-8859-7"), 0x0 },
  334. { TEXT("ELOT_928"), 0, 0, TEXT("iso-8859-7"), 0x0 },
  335. { TEXT("greek"), 0, 0, TEXT("iso-8859-7"), 0x0 },
  336. { TEXT("greek8"), 0, 0, TEXT("iso-8859-7"), 0x0 },
  337. { TEXT("hebrew"), 0, 0, TEXT("iso-8859-8"), 0x0 },
  338. { TEXT("IBM367"), 0, 0, TEXT("iso-8859-1"), 0x0 },
  339. { TEXT("ibm819"), 0, 0, TEXT("iso-8859-1"), 0x0 },
  340. { TEXT("ISO_646.irv:1991"), 0, 0, TEXT("iso-8859-1"), 0x4 },
  341. { TEXT("iso_8859-1"), 0, 0, TEXT("iso-8859-1"), 0x4 },
  342. { TEXT("iso_8859-1:1987"), 0, 0, TEXT("iso-8859-1"), 0x4 },
  343. { TEXT("iso_8859-2"), 0, 0, TEXT("iso-8859-2"), 0x0 },
  344. { TEXT("iso_8859-2:1987"), 0, 0, TEXT("iso-8859-2"), 0x0 },
  345. { TEXT("ISO_8859-4"), 0, 0, TEXT("iso-8859-4"), 0x0 },
  346. { TEXT("ISO_8859-5"), 0, 0, TEXT("iso-8859-5"), 0x0 },
  347. { TEXT("ISO_8859-7"), 0, 0, TEXT("iso-8859-7"), 0x0 },
  348. { TEXT("ISO_8859-8"), 0, 0, TEXT("iso-8859-8"), 0x0 },
  349. { TEXT("ISO_8859-9"), 0, 0, TEXT("iso-8859-9"), 0x0 },
  350. { TEXT("ISO646-US"), 0, 0, TEXT("iso-8859-1"), 0x4 },
  351. { TEXT("iso8859-1"), 0, 0, TEXT("iso-8859-1"), 0x4 },
  352. { TEXT("iso-ir-100"), 0, 0, TEXT("iso-8859-1"), 0x4 },
  353. { TEXT("iso-ir-101"), 0, 0, TEXT("iso-8859-2"), 0x0 },
  354. { TEXT("iso-ir-110"), 0, 0, TEXT("iso-8859-4"), 0x0 },
  355. { TEXT("iso-ir-126"), 0, 0, TEXT("iso-8859-7"), 0x0 },
  356. { TEXT("iso-ir-138"), 0, 0, TEXT("iso-8859-8"), 0x0 },
  357. { TEXT("iso-ir-144"), 0, 0, TEXT("iso-8859-5"), 0x0 },
  358. { TEXT("iso-ir-148"), 0, 0, TEXT("iso-8859-9"), 0x0 },
  359. { TEXT("iso-ir-58"), 0, 0, TEXT("gb2312"), 0x0 },
  360. { TEXT("iso-ir-6"), 0, 0, TEXT("iso-8859-1"), 0x4 },
  361. { TEXT("korean"), 0, 0, TEXT("ks_c_5601-1987"), 0x0 },
  362. { TEXT("ks_c_5601"), 0, 0, TEXT("ks_c_5601-1987"), 0x0 },
  363. { TEXT("l2"), 0, 0, TEXT("iso-8859-2"), 0x0 },
  364. { TEXT("l4"), 0, 0, TEXT("iso-8859-4"), 0x0 },
  365. { TEXT("l5"), 0, 0, TEXT("iso-8859-9"), 0x4 },
  366. { TEXT("latin1"), 0, 0, TEXT("iso-8859-1"), 0x4 },
  367. { TEXT("latin2"), 0, 0, TEXT("iso-8859-2"), 0x0 },
  368. { TEXT("latin4"), 0, 0, TEXT("iso-8859-4"), 0x0 },
  369. { TEXT("latin5"), 0, 0, TEXT("iso-8859-9"), 0x4 },
  370. { TEXT("ms_Kanji"), 0, 0, TEXT("shift_jis"), 0x0 },
  371. { TEXT("shift-jis"), 0, 0, TEXT("shift_jis"), 0x0 },
  372. { TEXT("unicode-2-0-utf-8"), 0, 0, TEXT("utf-8"), 0x0 },
  373. { TEXT("us-ascii"), 0, 0, TEXT("iso-8859-1"), 0x0 },
  374. { TEXT("us"), 0, 0, TEXT("iso-8859-1"), 0x0 },
  375. { TEXT("x-cp1250"), 0, 0, TEXT("Windows-1250"), 0x0 },
  376. { TEXT("x-cp1251"), 0, 0, TEXT("Windows-1251"), 0x0 },
  377. { TEXT("x-x-big5"), 0, 0, TEXT("big5"), 0x0 },
  378. { TEXT("csISO2022JP"), 0, 0, TEXT("_iso-2022-jp$ESC"), 0x4 },
  379. { TEXT("csKOI8R"), 0, 0, TEXT("koi8-r"), 0x0 },
  380. { TEXT("Extended_UNIX_Code_Packed_Format_for_Japanese"), 0, 0, TEXT("euc-jp"), 0x0 },
  381. { TEXT("GB_2312-80"), 0, 0, TEXT("gb2312"), 0x0 },
  382. { TEXT("GBK"), 0, 0, TEXT("gb2312"), 0x0 },
  383. { TEXT("ISO_8859-4:1988"), 0, 0, TEXT("iso-8859-4"), 0x0 },
  384. { TEXT("ISO_8859-5:1988"), 0, 0, TEXT("iso-8859-5"), 0x0 },
  385. { TEXT("ISO_8859-7:1987"), 0, 0, TEXT("iso-8859-7"), 0x0 },
  386. { TEXT("ISO_8859-8:1988"), 0, 0, TEXT("iso-8859-8"), 0x0 },
  387. { TEXT("ISO_8859-9:1989"), 0, 0, TEXT("iso-8859-9"), 0x0 },
  388. { TEXT("iso8859-2"), 0, 0, TEXT("iso-8859-2"), 0x0 },
  389. { TEXT("koi"), 0, 0, TEXT("koi8-r"), 0x0 },
  390. { TEXT("Windows-1254"), 0, 0, TEXT("iso-8859-9"), 0x0 },
  391. { TEXT("DOS-720"), 1256, 720, NULL, 0x0 },
  392. { TEXT("DOS-862"), 1255, 862, NULL, 0x0 },
  393. { TEXT("DOS-874"), 874, 874, NULL, 0x0 },
  394. { TEXT("ASMO-708"), 1256, 708, NULL, 0x0 },
  395. { TEXT("csEUCKR"), 0, 0, TEXT("ks_c_5601-1987"), 0x0 },
  396. { TEXT("csISOLatin1"), 0, 0, TEXT("windows-1252"), 0x0 },
  397. { TEXT("iso-ir-111"), 0, 0, TEXT("iso-8859-4"), 0x0 },
  398. { TEXT("iso-ir-149"), 0, 0, TEXT("ks_c_5601-1987"), 0x0 },
  399. { TEXT("KSC_5601"), 0, 0, TEXT("ks_c_5601-1987"), 0x0 },
  400. { TEXT("KSC5601"), 0, 0, TEXT("ks_c_5601-1987"), 0x0 },
  401. { TEXT("ks_c_5601-1989"), 0, 0, TEXT("ks_c_5601-1987"), 0x0 },
  402. { TEXT("l1"), 0, 0, TEXT("windows-1252"), 0x0 },
  403. { TEXT("cp1256"), 0, 0, TEXT("windows-1256"), 0x0 },
  404. { TEXT("logical"), 0, 0, TEXT("windows-1255"), 0x0 },
  405. { TEXT("csISOLatinArabic"), 0, 0, TEXT("iso-8859-6"), 0x0 },
  406. { TEXT("ECMA-114"), 0, 0, TEXT("iso-8859-6"), 0x0 },
  407. { TEXT("visual"), 0, 0, TEXT("iso-8859-8"), 0x0 },
  408. { TEXT("ISO-8859-8 Visual"), 0, 0, TEXT("iso-8859-8"), 0x0 },
  409. { TEXT("ISO_8859-6"), 0, 0, TEXT("iso-8859-6"), 0x0 },
  410. { TEXT("iso-ir-127"), 0, 0, TEXT("iso-8859-6"), 0x0 },
  411. { TEXT("ISO_8859-6:1987"), 0, 0, TEXT("iso-8859-6"), 0x0 },
  412. { TEXT("arabic"), 0, 0, TEXT("iso-8859-6"), 0x0 },
  413. { NULL, 0, 0, NULL, 0 }
  414. };
  415. //
  416. // Codepage registry data at MIME\Database
  417. //
  418. typedef struct tagREGCODEPAGE
  419. {
  420. LPCTSTR szCodePage;
  421. LPCTSTR szHeaderCharset;
  422. LPCTSTR szBodyCharset;
  423. LPCTSTR szWebCharset;
  424. UINT uidFixedWidthFont;
  425. UINT uidProportionalFont;
  426. UINT uidDescription;
  427. DWORD dwFamily;
  428. DWORD dwLevel;
  429. DWORD dwEncoding;
  430. DWORD dwCodePageMask;
  431. } REGCODEPAGE, *LPREGCODEPAGE;
  432. const REGCODEPAGE regCodePage[] =
  433. {
  434. { TEXT("1200"), NULL, TEXT("unicode"), NULL, IDS_FONT_WESTERN_FIXED, IDS_FONT_WESTERN_PROP, IDS_DESC_1200, 0, 0x00000204, 0x00000101, 0xA0 },
  435. { TEXT("1201"), NULL, TEXT("unicodeFFFE"), NULL, IDS_FONT_WESTERN_FIXED, IDS_FONT_WESTERN_PROP, IDS_DESC_1201, 1200, 0x00000000, 0x00000101,0xE0 },
  436. { TEXT("1250"), NULL, TEXT("iso-8859-2"), TEXT("windows-1250"), IDS_FONT_WESTERN_FIXED, IDS_FONT_WESTERN_PROP, IDS_DESC_1250, 0, 0x00000303, 0x00000202, 0xA0 },
  437. { TEXT("1251"), NULL, TEXT("koi8-r"), TEXT("windows-1251"), IDS_FONT_WESTERN_FIXED, IDS_FONT_WESTERN_PROP, IDS_DESC_1251, 0, 0x00000303, 0x00000202, 0xA0 },
  438. { TEXT("1252"), NULL, TEXT("iso-8859-1"), TEXT("iso-8859-1"), IDS_FONT_WESTERN_FIXED, IDS_FONT_WESTERN_PROP, IDS_DESC_1252, 0, 0x00000707, 0x00000000, 0xA4 },
  439. { TEXT("1253"), NULL, TEXT("iso-8859-7"), TEXT("windows-1253"), IDS_FONT_WESTERN_FIXED, IDS_FONT_WESTERN_PROP, IDS_DESC_1253, 0, 0x00000303, 0x00000101, 0x100A6 },
  440. { TEXT("1254"), NULL, TEXT("iso-8859-9"), TEXT("iso-8859-9"), IDS_FONT_WESTERN_FIXED, IDS_FONT_WESTERN_PROP, IDS_DESC_1254, 0, 0x00000707, 0x00000202, 0xA0 },
  441. { TEXT("1255"), NULL, TEXT("iso-8859-8-i"), TEXT("windows-1255"), IDS_FONT_WESTERN_FIXED, IDS_FONT_WESTERN_PROP, IDS_DESC_1255, 0, 0x00000303, 0x00000101, 0xA2 },
  442. { TEXT("1256"), NULL, TEXT("iso-8859-6"), TEXT("windows-1256"), IDS_FONT_WESTERN_FIXED, IDS_FONT_WESTERN_PROP, IDS_DESC_1256, 0, 0x00000303, 0x00000101, 0xA0 },
  443. { TEXT("1257"), NULL, TEXT("iso-8859-4"), TEXT("windows-1257"), IDS_FONT_WESTERN_FIXED, IDS_FONT_WESTERN_PROP, IDS_DESC_1257, 0, 0x00000707, 0x00000202, 0xA0 },
  444. { TEXT("1258"), NULL, TEXT("windows-1258"), TEXT("windows-1258"), IDS_FONT_WESTERN_FIXED, IDS_FONT_WESTERN_PROP, IDS_DESC_1258, 0, 0x00000101, 0x00000000, 0xA0 },
  445. { TEXT("20866"), NULL, TEXT("koi8-r"), NULL, 0, 0, IDS_DESC_20866, 1251, 0x00000707, 0x00000101, 0xA0 },
  446. { TEXT("21866"), NULL, TEXT("koi8-ru"), NULL, 0, 0, IDS_DESC_21866, 1251, 0x00000707, 0x00000101, 0xA0 },
  447. { TEXT("28592"), NULL, TEXT("iso-8859-2"), NULL, 0, 0, IDS_DESC_28592, 1250, 0x00000707, 0x00000000, 0xA0 },
  448. { TEXT("28593"), NULL, TEXT("iso-8859-3"), NULL, 0, 0, IDS_DESC_28593, 1254, 0x00000701, 0x00000000, 0xA0 },
  449. { TEXT("28594"), NULL, TEXT("iso-8859-4"), NULL, 0, 0, IDS_DESC_28594, 1257, 0x00000301, 0x00000000, 0xA0 },
  450. { TEXT("28595"), NULL, TEXT("iso-8859-5"), NULL, 0, 0, IDS_DESC_28595, 1251, 0x00000707, 0x00000101, 0xA0 },
  451. { TEXT("28596"), NULL, TEXT("iso-8859-6"), NULL, 0, 0, IDS_DESC_28596, 1256, 0x00000707, 0x00000000, 0xA0 },
  452. { TEXT("28597"), NULL, TEXT("iso-8859-7"), NULL, 0, 0, IDS_DESC_28597, 1253, 0x00000707, 0x00000101, 0xA2 },
  453. { TEXT("50000"), NULL, TEXT("x-user-defined"), NULL, IDS_FONT_WESTERN_FIXED, IDS_FONT_UNICODE_PROP, IDS_DESC_50000, 0, 0x00000303, 0x00000000, 0xA0 },
  454. { TEXT("50220"), NULL, TEXT("iso-2022-jp"), NULL, 0, 0, IDS_DESC_50220, 932, 0x00000101, 0x00000000, 0xE2 },
  455. { TEXT("50221"), NULL, TEXT("_iso-2022-jp$ESC"), TEXT("csISO2022JP"), 0, 0, IDS_DESC_50221, 932, 0x00000301, 0x00000000, 0xE6 },
  456. { TEXT("50222"), NULL, TEXT("_iso-2022-jp$SIO"), TEXT("iso-2022-jp"), 0, 0, IDS_DESC_50222, 932, 0x00000101, 0x00000000, 0xE6 },
  457. { TEXT("50225"), NULL, TEXT("iso-2022-kr"), TEXT("iso-2022-kr"), 0, 0, IDS_DESC_50225, 949, 0x00000101, 0x00000000, 0xA0 },
  458. { TEXT("50001"), NULL, TEXT("_autodetect_all"), NULL, 0, 0, IDS_DESC_50001, 0, 0x00000007, 0x00000101, 0xA2 },
  459. { TEXT("50932"), NULL, TEXT("_autodetect"), NULL, 0, 0, IDS_DESC_50932, 932, 0x00000007, 0x00000101, 0xA2 },
  460. { TEXT("50949"), NULL, TEXT("_autodetect_kr"), NULL, 0, 0, IDS_DESC_50949, 949, 0x00000001, 0x00000101, 0xA0 },
  461. { TEXT("51932"), NULL, TEXT("euc-jp"), NULL, 0, 0, IDS_DESC_51932, 932, 0x00000707, 0x00000101, 0xA2 },
  462. { TEXT("51949"), NULL, TEXT("euc-kr"), NULL, 0, 0, IDS_DESC_51949, 949, 0x00000000, 0x00000101, 0xE2 },
  463. { TEXT("52936"), NULL, TEXT("hz-gb-2312"), NULL, 0, 0, IDS_DESC_52936, 936, 0x00000303, 0x00000000, 0xA2 },
  464. { TEXT("65000"), NULL, TEXT("utf-7"), NULL, 0, 0, IDS_DESC_65000, 1200, 0x00000101, 0x00000000, 0xA0 },
  465. { TEXT("65001"), NULL, TEXT("utf-8"), NULL, 0, 0, IDS_DESC_65001, 1200, 0x00000303, 0x00000000, 0xA0 },
  466. { TEXT("852"), NULL, TEXT("ibm852"), NULL, 0, 0, IDS_DESC_852, 1250, 0x00000202, 0x00000000, 0xE0 },
  467. { TEXT("866"), NULL, TEXT("cp866"), NULL, 0, 0, IDS_DESC_866, 1251, 0x00000202, 0x00000000, 0xA0 },
  468. { TEXT("874"), NULL, TEXT("windows-874"), TEXT("windows-874"), IDS_FONT_THAI_FIXED, IDS_FONT_THAI_PROP, IDS_DESC_874, 0, 0x00000707, 0x00000101, 0x1B8 },
  469. { TEXT("932"), NULL, TEXT("iso-2022-jp"), TEXT("shift_jis"), IDS_FONT_JAPANESE_FIXED, IDS_FONT_JAPANESE_PROP, IDS_DESC_932, 0, 0x00000707, 0x00000101, 0xA2 },
  470. { TEXT("936"), NULL, TEXT("gb2312"), NULL, IDS_FONT_CHINESE_FIXED, IDS_FONT_CHINESE_PROP, IDS_DESC_936, 0, 0x00000707, 0x00000000, 0xA0 },
  471. { TEXT("949"), TEXT("euc-kr"), TEXT("euc-kr"), TEXT("ks_c_5601-1987"), IDS_FONT_KOREAN_FIXED, IDS_FONT_KOREAN_PROP, IDS_DESC_949, 0, 0x00000707, 0x00000101, 0xA7 },
  472. { TEXT("950"), NULL, TEXT("big5"), NULL, IDS_FONT_TAIWAN_FIXED, IDS_FONT_TAIWAN_PROP, IDS_DESC_950, 0, 0x00000707, 0x00000101, 0xA0 },
  473. { TEXT("28598"), NULL, TEXT("iso-8859-8"), NULL, 0, 0, IDS_DESC_28598, 1255, 0x00000707, 0x00000101, 0xA0 },
  474. { TEXT("38598"), NULL, TEXT("iso-8859-8-i"), NULL, IDS_FONT_HEBREW_FIXED, IDS_FONT_HEBREW_PROP, IDS_DESC_38598, 1255, 0x00000707, 0x00000101, 0xB8 },
  475. { TEXT("708"), NULL, TEXT("ASMO-708"), NULL, 0, 0, IDS_DESC_708, 1256, 0x00000707, 0, 0xA0 },
  476. { TEXT("720"), NULL, TEXT("DOS-720"), NULL, 0, 0, IDS_DESC_720, 1256, 0x00000707, 0, 0xA0 },
  477. { TEXT("862"), NULL, TEXT("DOS-862"), NULL, 0, 0, IDS_DESC_862, 1255, 0x00000707, 0, 0xA0 },
  478. { NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0x00000000, 0x00000000, 0x0 }
  479. };
  480. BOOL MimeDatabaseInfo(void)
  481. {
  482. HKEY hKey = NULL, hKeySub = NULL;
  483. TCHAR szKey[32], szValue[256];
  484. int i;
  485. BOOL bNewKey, bOverWrite;
  486. DWORD dwAction;
  487. BOOL bRet = TRUE;
  488. // MIME\Database\CodePage
  489. wsprintf(szKey, TEXT("%s\\%s"), szMIMEDatabase, szCodepage);
  490. if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwAction))
  491. {
  492. ASSERT(NULL != hKey);
  493. i = 0;
  494. bNewKey = (dwAction == REG_CREATED_NEW_KEY);
  495. while (regCodePage[i].szCodePage)
  496. {
  497. if (ERROR_SUCCESS == RegCreateKeyEx(hKey, regCodePage[i].szCodePage, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKeySub, &dwAction))
  498. {
  499. ASSERT(NULL != hKeySub);
  500. bOverWrite = (bNewKey || dwAction == REG_CREATED_NEW_KEY);
  501. if (regCodePage[i].szHeaderCharset)
  502. {
  503. if (ERROR_SUCCESS != PrivRegSetValueEx(hKeySub, szHeaderCharset, REG_SZ, (LPBYTE)regCodePage[i].szHeaderCharset, (lstrlen(regCodePage[i].szHeaderCharset) + 1) * sizeof(TCHAR), bOverWrite || (regCodePage[i].dwCodePageMask & BIT_HEADER_CHARSET)))
  504. bRet = FALSE;
  505. }
  506. else
  507. {
  508. if (regCodePage[i].dwCodePageMask & BIT_DEL_HEADER_CHARSET)
  509. {
  510. RegDeleteValue(hKeySub, szHeaderCharset);
  511. }
  512. }
  513. if (regCodePage[i].szBodyCharset)
  514. {
  515. if (ERROR_SUCCESS != PrivRegSetValueEx(hKeySub, szBodyCharset, REG_SZ, (LPBYTE)regCodePage[i].szBodyCharset, (lstrlen(regCodePage[i].szBodyCharset) + 1) * sizeof(TCHAR), bOverWrite || (regCodePage[i].dwCodePageMask & BIT_BODY_CHARSET)))
  516. bRet = FALSE;
  517. }
  518. else
  519. {
  520. if (regCodePage[i].dwCodePageMask & BIT_DEL_BODY_CHARSET)
  521. {
  522. RegDeleteValue(hKeySub, szBodyCharset);
  523. }
  524. }
  525. if (regCodePage[i].szWebCharset)
  526. {
  527. if (ERROR_SUCCESS != PrivRegSetValueEx(hKeySub, szWebCharset, REG_SZ, (LPBYTE)regCodePage[i].szWebCharset, (lstrlen(regCodePage[i].szWebCharset) + 1) * sizeof(TCHAR), bOverWrite || (regCodePage[i].dwCodePageMask & BIT_WEB_CHARSET)))
  528. bRet = FALSE;
  529. }
  530. else
  531. {
  532. if (regCodePage[i].dwCodePageMask & BIT_DEL_WEB_CHARSET)
  533. {
  534. RegDeleteValue(hKeySub, szWebCharset);
  535. }
  536. }
  537. if (regCodePage[i].uidFixedWidthFont)
  538. {
  539. LoadString(g_hInst, regCodePage[i].uidFixedWidthFont, szValue, sizeof(szValue));
  540. if (ERROR_SUCCESS != PrivRegSetValueEx(hKeySub, szFixedWidthFont, REG_SZ, (LPBYTE)szValue, (lstrlen(szValue) + 1) * sizeof(TCHAR), bOverWrite || (regCodePage[i].dwCodePageMask & BIT_WEB_FIXED_WIDTH_FONT)))
  541. bRet = FALSE;
  542. }
  543. else
  544. {
  545. if (regCodePage[i].dwCodePageMask & BIT_DEL_WEB_FIXED_WIDTH_FONT)
  546. {
  547. RegDeleteValue(hKeySub, szFixedWidthFont);
  548. }
  549. }
  550. if (regCodePage[i].uidProportionalFont)
  551. {
  552. LoadString(g_hInst, regCodePage[i].uidProportionalFont, szValue, sizeof(szValue));
  553. if (ERROR_SUCCESS != PrivRegSetValueEx(hKeySub, szProportionalFont, REG_SZ, (LPBYTE)szValue, (lstrlen(szValue) + 1) * sizeof(TCHAR), bOverWrite || (regCodePage[i].dwCodePageMask & BIT_PROPORTIONAL_FONT)))
  554. bRet = FALSE;
  555. }
  556. else
  557. {
  558. if (regCodePage[i].dwCodePageMask & BIT_DEL_PROPORTIONAL_FONT)
  559. {
  560. RegDeleteValue(hKeySub, szProportionalFont);
  561. }
  562. }
  563. if (regCodePage[i].uidDescription)
  564. {
  565. LANGID lid = GetSystemDefaultLangID();
  566. // Unsupported language resource?
  567. if (!_LoadStringExA(g_hInst, regCodePage[i].uidDescription, szValue, sizeof(szValue), lid))
  568. {
  569. // First try, primary language
  570. lid = MAKELANGID(PRIMARYLANGID(lid), SUBLANG_NEUTRAL);
  571. if (!_LoadStringExA(g_hInst, regCodePage[i].uidDescription, szValue, sizeof(szValue), lid))
  572. {
  573. // Last try, switch to English, US
  574. _LoadStringExA(g_hInst, regCodePage[i].uidDescription, szValue, sizeof(szValue), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
  575. }
  576. }
  577. if (ERROR_SUCCESS != PrivRegSetValueEx(hKeySub, szDescription, REG_SZ, (LPBYTE)szValue, (lstrlen(szValue) + 1) * sizeof(TCHAR), bOverWrite || (regCodePage[i].dwCodePageMask & BIT_DESCRIPTION)))
  578. bRet = FALSE;
  579. }
  580. else
  581. {
  582. if (regCodePage[i].dwCodePageMask & BIT_DEL_DESCRIPTION)
  583. {
  584. RegDeleteValue(hKeySub, szDescription);
  585. }
  586. }
  587. if (regCodePage[i].dwFamily)
  588. {
  589. if (ERROR_SUCCESS != PrivRegSetValueEx(hKeySub, szFamily, REG_DWORD, (LPBYTE)&regCodePage[i].dwFamily, sizeof(DWORD), bOverWrite || (regCodePage[i].dwCodePageMask & BIT_FAMILY)))
  590. bRet = FALSE;
  591. }
  592. else
  593. {
  594. if (regCodePage[i].dwCodePageMask & BIT_DEL_FAMILY)
  595. {
  596. RegDeleteValue(hKeySub, szFamily);
  597. }
  598. }
  599. if (regCodePage[i].dwLevel)
  600. {
  601. if (ERROR_SUCCESS != PrivRegSetValueEx(hKeySub, szLevel, REG_BINARY, (LPBYTE)&regCodePage[i].dwLevel, sizeof(DWORD), bOverWrite || (regCodePage[i].dwCodePageMask & BIT_LEVEL)))
  602. bRet = FALSE;
  603. }
  604. else
  605. {
  606. if (regCodePage[i].dwCodePageMask & BIT_DEL_LEVEL)
  607. {
  608. RegDeleteValue(hKeySub, szLevel);
  609. }
  610. }
  611. if (regCodePage[i].dwEncoding)
  612. {
  613. if (ERROR_SUCCESS != PrivRegSetValueEx(hKeySub, szEncoding, REG_BINARY, (LPBYTE)&regCodePage[i].dwEncoding, sizeof(DWORD), bOverWrite || (regCodePage[i].dwCodePageMask & BIT_ENCODING)))
  614. bRet = FALSE;
  615. }
  616. else
  617. {
  618. if (regCodePage[i].dwCodePageMask & BIT_DEL_ENCODING)
  619. {
  620. RegDeleteValue(hKeySub, szEncoding);
  621. }
  622. }
  623. RegCloseKey(hKeySub);
  624. hKeySub = NULL;
  625. }
  626. else
  627. bRet = FALSE;
  628. i++;
  629. }
  630. RegCloseKey(hKey);
  631. hKey = NULL;
  632. }
  633. else
  634. bRet = FALSE;
  635. // MIME\Database\Charset
  636. wsprintf(szKey, TEXT("%s\\%s"), szMIMEDatabase, szCharset);
  637. if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwAction))
  638. {
  639. ASSERT(NULL != hKey);
  640. i = 0;
  641. bNewKey = (dwAction == REG_CREATED_NEW_KEY);
  642. while (regCharset[i].szCharset)
  643. {
  644. if (ERROR_SUCCESS == RegCreateKeyEx(hKey, regCharset[i].szCharset, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKeySub, &dwAction))
  645. {
  646. ASSERT(NULL != hKeySub);
  647. bOverWrite = (bNewKey || dwAction == REG_CREATED_NEW_KEY);
  648. if (regCharset[i].szAliasForCharset)
  649. {
  650. if (ERROR_SUCCESS != PrivRegSetValueEx(hKeySub, szAliasForCharset, REG_SZ, (LPBYTE)regCharset[i].szAliasForCharset, (lstrlen(regCharset[i].szAliasForCharset) + 1) * sizeof(TCHAR), bOverWrite || (regCharset[i].dwCharsetMask & BIT_ALIAS_FOR_CHARSET)))
  651. bRet = FALSE;
  652. }
  653. else
  654. {
  655. if (ERROR_SUCCESS != PrivRegSetValueEx(hKeySub, szCodepage, REG_DWORD, (LPBYTE)&regCharset[i].dwCodePage, sizeof(DWORD), bOverWrite || (regCharset[i].dwCharsetMask & BIT_CODEPAGE)))
  656. bRet = FALSE;
  657. if (ERROR_SUCCESS != PrivRegSetValueEx(hKeySub, szInternetEncoding, REG_DWORD, (LPBYTE)&regCharset[i].dwInternetEncoding, sizeof(DWORD), bOverWrite || (regCharset[i].dwCharsetMask & BIT_INTERNET_ENCODING)))
  658. bRet = FALSE;
  659. }
  660. RegCloseKey(hKeySub);
  661. hKeySub = NULL;
  662. }
  663. else
  664. bRet = FALSE;
  665. i++;
  666. }
  667. RegCloseKey(hKey);
  668. hKey = NULL;
  669. }
  670. else
  671. bRet = FALSE;
  672. // MIME\Database\Rfc1766
  673. wsprintf(szKey, TEXT("%s\\%s"), szMIMEDatabase, szRfc1766);
  674. if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwAction))
  675. {
  676. ASSERT(NULL != hKey);
  677. i = 0;
  678. while (regRfc1766[i].szLCID)
  679. {
  680. TCHAR szBuf[256];
  681. LANGID lid = GetSystemDefaultLangID();
  682. if (!_LoadStringExA(g_hInst, regRfc1766[i].uidLCID, szBuf, sizeof(szBuf), lid))
  683. {
  684. // First try, primary language
  685. lid = MAKELANGID(PRIMARYLANGID(lid), SUBLANG_NEUTRAL);
  686. if (!_LoadStringExA(g_hInst, regRfc1766[i].uidLCID, szBuf, sizeof(szBuf), lid))
  687. {
  688. // Last try, switch to English, US
  689. _LoadStringExA(g_hInst, regRfc1766[i].uidLCID, szBuf, sizeof(szBuf), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
  690. }
  691. }
  692. wsprintf(szValue, TEXT("%s;%s"), regRfc1766[i].szAcceptLang, szBuf);
  693. if (ERROR_SUCCESS != PrivRegSetValueEx(hKey, regRfc1766[i].szLCID, REG_SZ, (LPBYTE)szValue, (lstrlen(szValue) + 1) * sizeof(TCHAR), bOverWrite))
  694. bRet = FALSE;
  695. i++;
  696. }
  697. RegCloseKey(hKey);
  698. hKey = NULL;
  699. }
  700. else
  701. bRet = FALSE;
  702. return bRet;
  703. }