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.

111 lines
3.0 KiB

  1. #include <tchar.h>
  2. #include <atlbase.h>
  3. extern CComModule _Module;
  4. #include <atlcom.h>
  5. #include <sphelper.h>
  6. //#include <ms1033srmap.h>
  7. //#include <ms1033srvendormap.h>
  8. #include <ms1033ttsmap.h>
  9. //#include <ms1033ltsmap.h>
  10. // This code does not ship
  11. // This code creates the registry entries for the vendor and lts lexicons. The lexicon
  12. // datafiles registered here are the ones checked in the slm source tree. This is not
  13. // done using a reg file because we need to compute the absolute path of the datafiles
  14. // which can be different on different machines because of different root slm directories.
  15. CSpUnicodeSupport g_Unicode;
  16. HRESULT AddPhoneConv(
  17. WCHAR *pszTokenKeyName,
  18. WCHAR *pszDescription,
  19. WCHAR *pszLanguage,
  20. WCHAR *pszAttribs,
  21. const CLSID *pclsid,
  22. WCHAR *pszPhoneMap)
  23. {
  24. HRESULT hr;
  25. CComPtr<ISpObjectToken> cpToken;
  26. CComPtr<ISpDataKey> cpDataKeyAttribs;
  27. hr = SpCreateNewTokenEx(
  28. SPCAT_PHONECONVERTERS,
  29. pszTokenKeyName,
  30. pclsid,
  31. pszDescription,
  32. 0,
  33. NULL,
  34. &cpToken,
  35. &cpDataKeyAttribs);
  36. if (SUCCEEDED(hr) && pszAttribs != NULL)
  37. {
  38. hr = cpDataKeyAttribs->SetStringValue(L"Type", pszAttribs);
  39. }
  40. if (SUCCEEDED(hr) && pszLanguage != NULL)
  41. {
  42. hr = cpDataKeyAttribs->SetStringValue(L"Language", pszLanguage);
  43. }
  44. if (SUCCEEDED(hr) && pszPhoneMap)
  45. {
  46. hr = cpToken->SetStringValue(L"PhoneMap", pszPhoneMap);
  47. }
  48. return hr;
  49. }
  50. int wmain()
  51. {
  52. HRESULT hr;
  53. hr = CoInitialize(NULL);
  54. CComPtr<ISpObjectTokenCategory> cpPhoneConvCategory;
  55. if (SUCCEEDED(hr))
  56. {
  57. hr = SpGetCategoryFromId(SPCAT_PHONECONVERTERS, &cpPhoneConvCategory, TRUE);
  58. if (SUCCEEDED(hr))
  59. {
  60. CComPtr<ISpDataKey> cpTokens;
  61. if (SUCCEEDED(cpPhoneConvCategory->OpenKey(L"Tokens", &cpTokens)))
  62. {
  63. // Delete old phone converters.
  64. WCHAR * pszSubKeyName = NULL;
  65. while (SUCCEEDED(cpTokens->EnumKeys(0, &pszSubKeyName)))
  66. {
  67. // Since NT doesn't allow recursive delete, need to delete Attributes subkey first.
  68. {
  69. CComPtr<ISpDataKey> cpPhoneKey;
  70. hr = cpTokens->OpenKey(pszSubKeyName, &cpPhoneKey);
  71. if (SUCCEEDED(hr))
  72. hr = cpPhoneKey->DeleteKey(L"Attributes");
  73. }
  74. if (SUCCEEDED(hr))
  75. hr = cpTokens->DeleteKey(pszSubKeyName);
  76. CoTaskMemFree(pszSubKeyName);
  77. if (FAILED(hr))
  78. break;
  79. }
  80. }
  81. }
  82. }
  83. cpPhoneConvCategory.Release();
  84. if (SUCCEEDED(hr))
  85. hr = AddPhoneConv(L"English", L"English Phone Converter", L"409", NULL, &CLSID_SpPhoneConverter, pszms1033ttsmap);
  86. CoUninitialize();
  87. return SUCCEEDED(hr)
  88. ? 0
  89. : -1;
  90. }