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.

74 lines
2.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1998
  6. //
  7. // File: pch.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "pch.h"
  11. #ifdef _ATL_STATIC_REGISTRY
  12. #include <statreg.h>
  13. #include <statreg.cpp>
  14. #endif
  15. #include <atlimpl.cpp>
  16. #include <atlwin.cpp>
  17. HRESULT WINAPI COuDelegComModule::UpdateRegistryCLSID(const CLSID& clsid, BOOL bRegister)
  18. {
  19. static const WCHAR szIPS32[] = _T("InprocServer32");
  20. static const WCHAR szCLSID[] = _T("CLSID");
  21. HRESULT hRes = S_OK;
  22. LPOLESTR lpOleStrCLSIDValue;
  23. ::StringFromCLSID(clsid, &lpOleStrCLSIDValue);
  24. CRegKey key;
  25. if (bRegister)
  26. {
  27. LONG lRes = key.Open(HKEY_CLASSES_ROOT, szCLSID);
  28. if (lRes == ERROR_SUCCESS)
  29. {
  30. lRes = key.Create(key, lpOleStrCLSIDValue);
  31. if (lRes == ERROR_SUCCESS)
  32. {
  33. WCHAR szModule[_MAX_PATH+1];
  34. ZeroMemory(szModule,sizeof(szModule));
  35. if(_MAX_PATH == ::GetModuleFileName(m_hInst, szModule, _MAX_PATH))
  36. {
  37. //GetModuleFileName truncated szModule
  38. return E_FAIL;
  39. }
  40. key.SetKeyValue(szIPS32, szModule);
  41. }
  42. }
  43. if (lRes != ERROR_SUCCESS)
  44. hRes = HRESULT_FROM_WIN32(lRes);
  45. }
  46. else
  47. {
  48. key.Attach(HKEY_CLASSES_ROOT);
  49. if (key.Open(key, szCLSID) == ERROR_SUCCESS)
  50. key.RecurseDeleteKey(lpOleStrCLSIDValue);
  51. }
  52. ::CoTaskMemFree(lpOleStrCLSIDValue);
  53. return hRes;
  54. }
  55. BOOL COuDelegComModule::InitClipboardFormats()
  56. {
  57. _ASSERTE(m_cfDsObjectNames == 0);
  58. m_cfDsObjectNames = ::RegisterClipboardFormat(CFSTR_DSOBJECTNAMES);
  59. _ASSERTE(m_cfParentHwnd == 0);
  60. m_cfParentHwnd = ::RegisterClipboardFormat(CFSTR_DS_PARENTHWND);
  61. _ASSERTE(m_cfDsopSelectionList == 0);
  62. m_cfDsopSelectionList = RegisterClipboardFormat(CFSTR_DSOP_DS_SELECTION_LIST);
  63. return (m_cfDsObjectNames != 0) && (m_cfParentHwnd != 0) && (m_cfDsopSelectionList != 0);
  64. }