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.

211 lines
5.0 KiB

  1. /**************************************************************************\
  2. * Module Name: softkbd.cpp
  3. *
  4. * Copyright (c) 1985 - 2000, Microsoft Corporation
  5. *
  6. * Main functions for Soft Keyboard Component.
  7. *
  8. * History:
  9. * 28-March-2000 weibz Created
  10. \**************************************************************************/
  11. #include "private.h"
  12. #include "resource.h"
  13. #include <initguid.h>
  14. #include "SoftKbd.h"
  15. #include "SoftKbdc.h"
  16. #include "SoftkbdIMX.h"
  17. #include "regimx.h"
  18. #include "catutil.h"
  19. #include "mui.h"
  20. #include "immxutil.h"
  21. #ifdef DEBUG
  22. DWORD g_dwThreadDllMain = 0;
  23. #endif
  24. HINSTANCE g_hInst;
  25. // used by COM server
  26. HINSTANCE GetServerHINSTANCE(void)
  27. {
  28. return g_hInst;
  29. }
  30. BEGIN_COCLASSFACTORY_TABLE
  31. DECLARE_COCLASSFACTORY_ENTRY(CLSID_SoftKbd, CSoftKbd, TEXT("SoftKbd Class"))
  32. DECLARE_COCLASSFACTORY_ENTRY(CLSID_SoftkbdIMX, CSoftkbdIMX, TEXT("SoftKbdIMX Class"))
  33. DECLARE_COCLASSFACTORY_ENTRY(CLSID_SoftkbdRegistry, CSoftkbdRegistry, TEXT("SoftKbdRegistry Class"))
  34. END_COCLASSFACTORY_TABLE
  35. const GUID c_guidProfile = { /* 0965500c-82f3-49c2-9f00-01c2feacaa0b */
  36. 0x0965500c,
  37. 0x82f3,
  38. 0x49c2,
  39. {0x9f, 0x00, 0x01, 0xc2, 0xfe, 0xac, 0xaa, 0x0b}
  40. };
  41. const GUID c_guidProfileSym = { // b2a54871-05f6-4bfc-b97d-0fdf0cbfa57d
  42. 0xb2a54871,
  43. 0x05f6,
  44. 0x4bfc,
  45. {0xb9, 0x7d, 0x0f, 0xdf, 0x0c, 0xbf, 0xa5, 0x7d}
  46. };
  47. extern REGTIPLANGPROFILE c_rgProf[] =
  48. {
  49. {0, &GUID_NULL, L"", L"", 0, 0}
  50. };
  51. //+---------------------------------------------------------------------------
  52. //
  53. // ProcessAttach
  54. //
  55. //----------------------------------------------------------------------------
  56. BOOL ProcessAttach(HINSTANCE hInstance)
  57. {
  58. if (!g_cs.Init())
  59. return FALSE;
  60. CcshellGetDebugFlags();
  61. Dbg_MemInit(TEXT("SOFTKBDIMX"), NULL);
  62. g_hInst = hInstance;
  63. MuiLoadResource(hInstance, TEXT("softkbd.dll"));
  64. return TRUE;
  65. }
  66. //+---------------------------------------------------------------------------
  67. //
  68. // ProcessDettach
  69. //
  70. //----------------------------------------------------------------------------
  71. void ProcessDettach(HINSTANCE hInstance)
  72. {
  73. MuiClearResource();
  74. g_cs.Delete();
  75. Dbg_MemUninit();
  76. }
  77. /////////////////////////////////////////////////////////////////////////////
  78. // DLL Entry Point
  79. extern "C"
  80. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  81. {
  82. BOOL bRet = TRUE;
  83. #ifdef DEBUG
  84. g_dwThreadDllMain = GetCurrentThreadId();
  85. #endif
  86. switch (dwReason)
  87. {
  88. case DLL_PROCESS_ATTACH:
  89. //
  90. // Now real DllEntry point is _DllMainCRTStartup.
  91. // _DllMainCRTStartup does not call our DllMain(DLL_PROCESS_DETACH)
  92. // if our DllMain(DLL_PROCESS_ATTACH) fails.
  93. // So we have to clean this up.
  94. //
  95. if (!ProcessAttach(hInstance))
  96. {
  97. ProcessDettach(hInstance);
  98. bRet = FALSE;
  99. }
  100. break;
  101. case DLL_THREAD_ATTACH:
  102. break;
  103. case DLL_PROCESS_DETACH:
  104. ProcessDettach(hInstance);
  105. break;
  106. case DLL_THREAD_DETACH:
  107. break;
  108. }
  109. #ifdef DEBUG
  110. g_dwThreadDllMain = 0;
  111. #endif
  112. return bRet;
  113. }
  114. /////////////////////////////////////////////////////////////////////////////
  115. // Used to determine whether the DLL can be unloaded by OLE
  116. STDAPI DllCanUnloadNow(void)
  117. {
  118. return COMBase_DllCanUnloadNow();
  119. }
  120. /////////////////////////////////////////////////////////////////////////////
  121. // Returns a class factory to create an object of the requested type
  122. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  123. {
  124. return COMBase_DllGetClassObject(rclsid, riid, ppv);
  125. }
  126. /////////////////////////////////////////////////////////////////////////////
  127. // DllRegisterServer - Adds entries to the system registry
  128. STDAPI DllRegisterServer(void)
  129. {
  130. HRESULT hr = E_FAIL;
  131. TFInitLib();
  132. // registers object, typelib and all interfaces in typelib
  133. if (COMBase_DllRegisterServer() != S_OK)
  134. goto Exit;
  135. if (!RegisterTIP(g_hInst, CLSID_SoftkbdIMX, L"On-screen keyboard", c_rgProf))
  136. goto Exit;
  137. if ( FAILED(RegisterCategory(CLSID_SoftkbdIMX, GUID_TFCAT_TIP_HANDWRITING, CLSID_SoftkbdIMX)))
  138. goto Exit;
  139. hr = S_OK;
  140. Exit:
  141. TFUninitLib( );
  142. return hr;
  143. }
  144. /////////////////////////////////////////////////////////////////////////////
  145. // DllUnregisterServer - Removes entries from the system registry
  146. STDAPI DllUnregisterServer(void)
  147. {
  148. HRESULT hr=E_FAIL;
  149. TFInitLib();
  150. if (COMBase_DllUnregisterServer() != S_OK)
  151. goto Exit;
  152. if (FAILED(UnregisterCategory(CLSID_SoftkbdIMX, GUID_TFCAT_TIP_HANDWRITING, CLSID_SoftkbdIMX)))
  153. goto Exit;
  154. if (!UnregisterTIP(CLSID_SoftkbdIMX))
  155. goto Exit;
  156. hr=S_OK;
  157. Exit:
  158. TFUninitLib( );
  159. return hr;
  160. }