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.

104 lines
2.4 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. #ifndef __SERVICETHREAD__
  3. #define __SERVICETHREAD__
  4. #pragma once
  5. #include "SshWbemHelpers.h"
  6. #include "SimpleArray.h"
  7. #define WM_ASYNC_CIMOM_CONNECTED (WM_USER + 20)
  8. #define WM_CIMOM_RECONNECT (WM_USER + 21)
  9. extern const wchar_t* MMC_SNAPIN_MACHINE_NAME;
  10. void __cdecl WbemServiceConnectThread(LPVOID lpParameter);
  11. class WbemServiceThread
  12. {
  13. public:
  14. friend void __cdecl WbemServiceConnectThread(LPVOID lpParameter);
  15. WbemServiceThread();
  16. virtual ~WbemServiceThread();
  17. LONG AddRef(){ return InterlockedIncrement(&m_cRef); };
  18. LONG Release(){ LONG lTemp = InterlockedDecrement(&m_cRef); if (0 == lTemp) delete this; return lTemp; };
  19. bstr_t m_machineName;
  20. bstr_t m_nameSpace;
  21. HRESULT m_hr;
  22. CRITICAL_SECTION notifyLock;
  23. typedef enum {notStarted,
  24. locating,
  25. connecting,
  26. threadError,
  27. error,
  28. cancelled,
  29. ready} ServiceStatus;
  30. ServiceStatus m_status;
  31. // Start the connection attempt.
  32. HRESULT Connect(bstr_t machineName,
  33. bstr_t ns,
  34. bool threaded ,
  35. LOGIN_CREDENTIALS *credentials , HWND = 0);
  36. bool Connect(IDataObject *_pDataObject, HWND hWnd = 0);
  37. HRESULT ReConnect(void)
  38. {
  39. DisconnectServer();
  40. return ConnectNow();
  41. }
  42. // Returns true if a msg will be sent.
  43. // Returns false if its already over.
  44. bool NotifyWhenDone(HWND dlg);
  45. void Cancel(void);
  46. void DisconnectServer(void);
  47. typedef CSimpleArray<HWND> NOTIFYLIST;
  48. NOTIFYLIST m_notify;
  49. bool LocalConnection(void);
  50. void SendPtr(HWND hwnd);
  51. CWbemServices GetPtr(void);
  52. CWbemServices m_WbemServices;
  53. // this is set by the SomePage::OnConnect
  54. // and it is a "correctly marshaled version of the pointer"
  55. CWbemServices m_realServices; // lives on the connection thread.
  56. // DONT had this out directly. Use
  57. // the Notify().
  58. private:
  59. HRESULT ConnectNow(bool real = false);
  60. void MachineName(IDataObject *_pDataObject, bstr_t *name);
  61. static CLIPFORMAT MACHINE_NAME;
  62. HANDLE m_doWork, m_ptrReady;
  63. #define CT_CONNECT 0
  64. #define CT_EXIT 1
  65. #define CT_GET_PTR 2
  66. #define CT_SEND_PTR 3
  67. int m_threadCmd;
  68. UINT_PTR m_hThread;
  69. void Notify(IWbemServices * service);
  70. void NotifyError(void);
  71. HRESULT EnsureThread(void);
  72. HWND m_hWndGetPtr;
  73. IStream *m_pStream;
  74. LOGIN_CREDENTIALS *m_credentials;
  75. LONG m_cRef;
  76. };
  77. #endif __SERVICETHREAD__