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.

85 lines
2.2 KiB

  1. //+---------------------------------------------------------------------
  2. //
  3. // File: rotutils.cxx
  4. //
  5. // Contents: Running Object Table helper functions
  6. //
  7. //----------------------------------------------------------------------
  8. #include "headers.hxx"
  9. #pragma hdrstop
  10. //+---------------------------------------------------------------
  11. //
  12. // Function: RegisterAsRunning
  13. //
  14. // Synopsis: Registers the object in the Running Object Table
  15. //
  16. // Arguments: [lpUnk] -- the object being registered
  17. // [lpmkFull] -- the full moniker to the object
  18. // [lpdwRegister] -- where the registration value will be
  19. // returned.
  20. //
  21. // Notes: c.f. RevokeAsRunning
  22. //
  23. //----------------------------------------------------------------
  24. void
  25. RegisterAsRunning(LPUNKNOWN lpUnk,
  26. LPMONIKER lpmkFull,
  27. DWORD FAR* lpdwRegister)
  28. {
  29. LPRUNNINGOBJECTTABLE pROT;
  30. HRESULT r;
  31. if (OK(r = GetRunningObjectTable(0,(LPRUNNINGOBJECTTABLE FAR*)&pROT)))
  32. {
  33. // if already registered, revoke
  34. if (*lpdwRegister != NULL)
  35. {
  36. pROT->Revoke(*lpdwRegister);
  37. *lpdwRegister = NULL;
  38. }
  39. // register as running if a valid moniker is passed
  40. if (lpmkFull)
  41. {
  42. pROT->Register(NULL, lpUnk, lpmkFull, lpdwRegister);
  43. }
  44. pROT->Release();
  45. }
  46. }
  47. //+---------------------------------------------------------------
  48. //
  49. // Function: RevokeAsRunning
  50. //
  51. // Synopsis: Revokes an objects registration in the Running Object Table
  52. //
  53. // Arguments: [lpdwRegister] -- points to where the registration value is
  54. // for the object. Will be set to NULL.
  55. //
  56. // Notes: c.f. RegisterAsRunning
  57. //
  58. //----------------------------------------------------------------
  59. void
  60. RevokeAsRunning(DWORD FAR* lpdwRegister)
  61. {
  62. LPRUNNINGOBJECTTABLE pROT;
  63. HRESULT r;
  64. // if still registered, then revoke
  65. if (*lpdwRegister != NULL)
  66. {
  67. if (OK(r = GetRunningObjectTable(0,(LPRUNNINGOBJECTTABLE FAR*)&pROT)))
  68. {
  69. pROT->Revoke(*lpdwRegister);
  70. *lpdwRegister = NULL;
  71. pROT->Release();
  72. }
  73. }
  74. }