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.

64 lines
1.9 KiB

  1. #include <windows.h>
  2. #include "rulelex.h"
  3. #include "lexicon.h"
  4. #include "LexMgr.h"
  5. #include "chtbrkr.h"
  6. #include "IWBrKr.h"
  7. TCHAR tszLangSpecificKey[] = TEXT("System\\CurrentControlSet\\Control\\ContentIndex\\Language\\Chinese_Traditional");
  8. HRESULT COMRegister(
  9. BOOL fRegister)
  10. {
  11. HKEY hKey;
  12. WCHAR tszCLSID[MAX_PATH];
  13. TCHAR tszBuf[MAX_PATH * 2 + 1];
  14. HRESULT hr = S_OK;
  15. //HKEY_CLASSES_ROOT\\CLSID\\CLSID_CHTBRKR, {E1B6B375-3412-11D3-A9E2-00AA0059F9F6};
  16. if (0 == StringFromGUID2(CLSID_CHTBRKR, tszCLSID, sizeof(tszCLSID) / sizeof(TCHAR))) {
  17. hr = S_FALSE;
  18. goto _exit;
  19. }
  20. lstrcpyn(tszBuf, TEXT("CLSID\\"), sizeof(tszBuf) / sizeof(TCHAR));
  21. wcsncat(tszBuf, tszCLSID, sizeof(tszBuf) / sizeof(TCHAR) - lstrlen(TEXT("CLSID\\")) - 1);
  22. if (fRegister) {
  23. wcsncat(tszBuf, TEXT("\\InprocServer32"), sizeof(tszBuf) / sizeof(TCHAR) - 1);
  24. if (RegCreateKey(HKEY_CLASSES_ROOT, tszBuf, &hKey) != ERROR_SUCCESS) {
  25. hr = S_FALSE;
  26. goto _exit;
  27. }
  28. RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)g_tszModuleFileName,
  29. lstrlen(g_tszModuleFileName) * sizeof(TCHAR));
  30. RegCloseKey(hKey);
  31. } else {
  32. RegDeleteKey(HKEY_CLASSES_ROOT, tszBuf);
  33. }
  34. // HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\ContentIndex\\
  35. // Language\\Chinese_Traditional
  36. /*
  37. if (RegCreateKey(HKEY_LOCAL_MACHINE, tszLangSpecificKey, &hKey) != ERROR_SUCCESS) {
  38. hr = S_FALSE;
  39. goto _exit;
  40. }
  41. if (fRegister) {
  42. RegSetValueEx(hKey, TEXT("WBreakerClass"), 0, REG_SZ, (LPBYTE)tszCLSID,
  43. lstrlen(tszCLSID) * sizeof (TCHAR));
  44. } else {
  45. RegDeleteValue(hKey, TEXT("WBreakerClass"));
  46. }
  47. */
  48. _exit:
  49. return hr;
  50. }
  51. STDAPI DllRegisterServer(void)
  52. {
  53. return COMRegister(TRUE);
  54. }
  55. STDAPI DllUnregisterServer(void)
  56. {
  57. return COMRegister(FALSE);
  58. }