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.

103 lines
2.2 KiB

  1. #include "stdafx.h"
  2. #pragma hdrstop
  3. #include "InternetGatewayFinder.h"
  4. #include "trayicon.h"
  5. CInternetGatewayFinder::CInternetGatewayFinder()
  6. {
  7. m_hWindow = NULL;
  8. }
  9. HRESULT CInternetGatewayFinder::Initialize(HWND hWindow)
  10. {
  11. HRESULT hr = S_OK;
  12. m_hWindow = hWindow;
  13. return hr;
  14. }
  15. HRESULT CInternetGatewayFinder::GetInternetGateway(BSTR DeviceId, IInternetGateway** ppInternetGateway)
  16. {
  17. HRESULT hr = S_OK;
  18. *ppInternetGateway = NULL;
  19. IInternetGateway* pInternetGateway;
  20. if(1 == SendMessage(m_hWindow, WM_APP_GETBEACON, 0, reinterpret_cast<LPARAM>(&pInternetGateway)))
  21. {
  22. *ppInternetGateway = pInternetGateway;
  23. // pass reference
  24. }
  25. else
  26. {
  27. hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
  28. }
  29. return hr;
  30. }
  31. CInternetGatewayFinderClassFactory::CInternetGatewayFinderClassFactory()
  32. {
  33. m_hWindow = NULL;
  34. }
  35. HRESULT CInternetGatewayFinderClassFactory::Initialize(HWND hWindow)
  36. {
  37. HRESULT hr = S_OK;
  38. m_hWindow = hWindow;
  39. return hr;
  40. }
  41. HRESULT CInternetGatewayFinderClassFactory::CreateInstance(IUnknown* pUnkOuter, REFIID riid, void** ppvObject)
  42. {
  43. HRESULT hr = S_OK;
  44. if(NULL != pUnkOuter)
  45. {
  46. hr = CLASS_E_NOAGGREGATION;
  47. }
  48. if(NULL == ppvObject)
  49. {
  50. hr = E_POINTER;
  51. }
  52. else
  53. {
  54. *ppvObject = NULL;
  55. }
  56. if(SUCCEEDED(hr))
  57. {
  58. CComObject<CInternetGatewayFinder>* pInternetGatewayFinder;
  59. hr = CComObject<CInternetGatewayFinder>::CreateInstance(&pInternetGatewayFinder);
  60. if(SUCCEEDED(hr))
  61. {
  62. pInternetGatewayFinder->AddRef();
  63. hr = pInternetGatewayFinder->Initialize(m_hWindow);
  64. if(SUCCEEDED(hr))
  65. {
  66. hr = pInternetGatewayFinder->QueryInterface(riid, ppvObject);
  67. // pass reference
  68. }
  69. pInternetGatewayFinder->Release();
  70. }
  71. }
  72. return hr;
  73. }
  74. HRESULT CInternetGatewayFinderClassFactory::LockServer(BOOL fLock)
  75. {
  76. HRESULT hr = S_OK;
  77. fLock ? _Module.Lock() : _Module.Unlock();
  78. return hr;
  79. }