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.

123 lines
1.9 KiB

  1. #include "precomp.h"
  2. #include "Confroom.h"
  3. // SDK includes
  4. #include "SDKInternal.h"
  5. #include "NmChannel.h"
  6. #include "NmChannelAppShare.h"
  7. #include "NmSharableApp.h"
  8. HRESULT CNmSharableAppObj::CreateInstance(HWND hWnd,
  9. LPCTSTR szName,
  10. INmSharableApp** ppNmSharableApp)
  11. {
  12. HRESULT hr = S_OK;
  13. CComObject<CNmSharableAppObj>* p = NULL;
  14. p = new CComObject<CNmSharableAppObj>(NULL);
  15. if (p != NULL)
  16. {
  17. if(SUCCEEDED(hr))
  18. {
  19. p->m_hWnd = hWnd;
  20. }
  21. if(ppNmSharableApp)
  22. {
  23. p->SetVoid(NULL);
  24. hr = p->QueryInterface(IID_INmSharableApp, reinterpret_cast<void**>(ppNmSharableApp));
  25. if(FAILED(hr))
  26. {
  27. delete p;
  28. *ppNmSharableApp = NULL;
  29. }
  30. }
  31. else
  32. {
  33. delete p;
  34. hr = E_POINTER;
  35. }
  36. }
  37. return hr;
  38. }
  39. STDMETHODIMP CNmSharableAppObj::GetName(BSTR *pbstrName)
  40. {
  41. HRESULT hr = E_POINTER;
  42. if(pbstrName)
  43. {
  44. TCHAR szName[MAX_PATH];
  45. hr = CNmChannelAppShareObj::GetSharableAppName(m_hWnd, szName, CCHMAX(szName));
  46. if(SUCCEEDED(hr))
  47. {
  48. *pbstrName = CComBSTR(szName).Copy();
  49. if(*pbstrName)
  50. {
  51. hr = S_OK;
  52. }
  53. else
  54. {
  55. hr = E_OUTOFMEMORY;
  56. }
  57. }
  58. }
  59. return hr;
  60. }
  61. STDMETHODIMP CNmSharableAppObj::GetHwnd(HWND * phwnd)
  62. {
  63. HRESULT hr = E_POINTER;
  64. if(phwnd)
  65. {
  66. *phwnd = m_hWnd;
  67. hr = S_OK;
  68. }
  69. return hr;
  70. }
  71. STDMETHODIMP CNmSharableAppObj::GetState(NM_SHAPP_STATE *puState)
  72. {
  73. HRESULT hr = E_POINTER;
  74. if(puState)
  75. {
  76. hr = ::GetWindowState(puState, m_hWnd);
  77. }
  78. return hr;
  79. }
  80. extern bool g_bSDKPostNotifications;
  81. STDMETHODIMP CNmSharableAppObj::SetState(NM_SHAPP_STATE uState)
  82. {
  83. HRESULT hr = E_UNEXPECTED;
  84. g_bSDKPostNotifications = true;
  85. if(NM_SHAPP_SHARED == uState)
  86. {
  87. hr = ::ShareWindow(m_hWnd);
  88. }
  89. else if(NM_SHAPP_NOT_SHARED == uState)
  90. {
  91. hr = ::UnShareWindow(m_hWnd);
  92. }
  93. g_bSDKPostNotifications = false;
  94. return hr;
  95. }