Leaked source code of windows server 2003
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.

171 lines
4.5 KiB

  1. /****************************************************************************
  2. CICERO.CPP
  3. Owner: cslim
  4. Copyright (c) 1997-1999 Microsoft Corporation
  5. Cicero Toolbar Handling
  6. History:
  7. 29-MAY-2000 cslim Ported from KKIME
  8. *****************************************************************************/
  9. #include "precomp.h"
  10. #include "cicero.h"
  11. #include "gdata.h"
  12. BOOL vfCicero = fFalse;
  13. #define SZCICEROMODULE "msctf.dll"
  14. HMODULE g_hCicero = (HMODULE)0;
  15. #define SZOLEAUTOMODULE "oleaut32.dll"
  16. HMODULE g_hOleAuto = (HMODULE)0;
  17. typedef HRESULT(* FPTF_CreateLangBarMgr)(ITfLangBarMgr **pppbm);
  18. static FPTF_CreateLangBarMgr pFPTF_CreateLangBarMgr = 0;
  19. typedef BSTR(* FPSysAllocString)(const OLECHAR* pOleSz);
  20. static FPSysAllocString pFPSysAllocString = 0;
  21. static BOOL IsDisabledTextServices();
  22. /*----------------------------------------------------------------------------
  23. CiceroInitialize
  24. Load Cicero Language bar
  25. ----------------------------------------------------------------------------*/
  26. BOOL WINAPI CiceroInitialize()
  27. {
  28. // Winlogon process wouldn't run Cicero
  29. if (vpInstData->dwSystemInfoFlags & IME_SYSINFO_WINLOGON
  30. || IsDisabledTextServices())
  31. return fFalse;
  32. if (g_hCicero == (HMODULE)0)
  33. {
  34. g_hCicero=LoadLibrary(SZCICEROMODULE);
  35. if (!g_hCicero)
  36. return fFalse;
  37. }
  38. if (g_hOleAuto == (HMODULE)0)
  39. {
  40. g_hOleAuto=LoadLibrary(SZOLEAUTOMODULE);
  41. if (!g_hOleAuto)
  42. return fFalse;
  43. }
  44. if (pFPTF_CreateLangBarMgr == NULL)
  45. pFPTF_CreateLangBarMgr = (FPTF_CreateLangBarMgr)GetProcAddress(g_hCicero, "TF_CreateLangBarMgr");
  46. if (pFPTF_CreateLangBarMgr)
  47. vfCicero = fTrue;
  48. if (pFPSysAllocString == NULL)
  49. pFPSysAllocString = (FPSysAllocString)GetProcAddress(g_hOleAuto, "SysAllocString");
  50. if (pFPSysAllocString)
  51. {
  52. // ok
  53. }
  54. return vfCicero;
  55. }
  56. /*----------------------------------------------------------------------------
  57. CiceroTerminate
  58. Terminate Cicero Language bar service
  59. ----------------------------------------------------------------------------*/
  60. BOOL WINAPI CiceroTerminate()
  61. {
  62. BOOL fRetCic = fFalse;
  63. BOOL fRetOle = fFalse;
  64. if (g_hCicero)
  65. {
  66. FreeLibrary(g_hCicero);
  67. g_hCicero = NULL;
  68. vfCicero = fFalse;
  69. fRetCic= fTrue;
  70. }
  71. if (g_hOleAuto)
  72. {
  73. FreeLibrary(g_hOleAuto);
  74. g_hOleAuto = NULL;
  75. fRetOle = fTrue;
  76. }
  77. if (fRetCic && fRetOle)
  78. return fTrue;
  79. else
  80. return fFalse;
  81. }
  82. /*----------------------------------------------------------------------------
  83. Cicero_CreateLangBarMgr
  84. Create Cicero Lang bar manager object
  85. ----------------------------------------------------------------------------*/
  86. HRESULT WINAPI Cicero_CreateLangBarMgr(ITfLangBarMgr **pppbm)
  87. {
  88. *pppbm = NULL;
  89. if (vfCicero && g_hCicero)
  90. return pFPTF_CreateLangBarMgr(pppbm);
  91. return S_FALSE;
  92. }
  93. /*----------------------------------------------------------------------------
  94. OurSysAllocString
  95. ----------------------------------------------------------------------------*/
  96. BSTR OurSysAllocString(const OLECHAR* pOleSz)
  97. {
  98. if (pFPSysAllocString)
  99. return pFPSysAllocString(pOleSz);
  100. return NULL;
  101. }
  102. //+---------------------------------------------------------------------------
  103. //
  104. // IsDisabledTextServices
  105. //
  106. // Copied from immxutil.cpp
  107. //----------------------------------------------------------------------------
  108. BOOL IsDisabledTextServices()
  109. {
  110. static const TCHAR c_szCTFKey[] = TEXT("SOFTWARE\\Microsoft\\CTF");
  111. static const TCHAR c_szDiableTim[] = TEXT("Disable Thread Input Manager");
  112. HKEY hKey;
  113. if (RegOpenKey(HKEY_CURRENT_USER, c_szCTFKey, &hKey) == ERROR_SUCCESS)
  114. {
  115. DWORD cb;
  116. DWORD dwDisableTim = 0;
  117. cb = sizeof(DWORD);
  118. RegQueryValueEx(hKey,
  119. c_szDiableTim,
  120. NULL,
  121. NULL,
  122. (LPBYTE)&dwDisableTim,
  123. &cb);
  124. RegCloseKey(hKey);
  125. //
  126. // Ctfmon disabling flag is set, so return fail CreateInstance.
  127. //
  128. if (dwDisableTim)
  129. return TRUE;
  130. }
  131. return FALSE;
  132. }