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.

88 lines
2.0 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. #ifndef __CONNECTTHREAD__
  3. #define __CONNECTTHREAD__
  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. #define CT_CONNECT 0
  10. #define CT_EXIT 1
  11. #define CT_GET_PTR 2
  12. #define CT_SEND_PTR 3
  13. extern const wchar_t* MMC_SNAPIN_MACHINE_NAME;
  14. void __cdecl WbemConnectThreadProc(LPVOID lpParameter);
  15. class WbemConnectThread
  16. {
  17. private:
  18. public:
  19. virtual ~WbemConnectThread();
  20. friend void __cdecl WbemConnectThreadProc(LPVOID lpParameter);
  21. WbemConnectThread();
  22. LONG AddRef(){ return InterlockedIncrement(&m_cRef); };
  23. LONG Release(){ LONG lTemp = InterlockedDecrement(&m_cRef); if (0 == lTemp) delete this; return lTemp; };
  24. // Start the connection attempt.
  25. HRESULT Connect(bstr_t machineName,
  26. bstr_t ns,
  27. bool threaded = true,
  28. LOGIN_CREDENTIALS *credentials = NULL);
  29. bool Connect(IDataObject *_pDataObject, HWND *hWnd = 0);
  30. // Returns true if a msg will be sent.
  31. // Returns false if its already over.
  32. bool NotifyWhenDone(HWND *dlg);
  33. void Cancel(void);
  34. void SendPtr(HWND hwnd);
  35. void DisconnectServer(void);
  36. typedef CSimpleArray<HWND *> NOTIFYLIST;
  37. bool isLocalConnection(void);
  38. typedef enum {
  39. notStarted,
  40. locating,
  41. connecting,
  42. threadError,
  43. error,
  44. cancelled,
  45. ready
  46. } ServiceStatus;
  47. CWbemServices m_WbemServices;
  48. HRESULT m_hr;
  49. ServiceStatus m_status;
  50. bstr_t m_machineName;
  51. bstr_t m_nameSpace;
  52. private:
  53. HRESULT ConnectNow();
  54. void MachineName(IDataObject *_pDataObject, bstr_t *name);
  55. static CLIPFORMAT MACHINE_NAME_1;
  56. void Notify(IStream *stream);
  57. HRESULT EnsureThread(void);
  58. int m_threadCmd;
  59. HWND m_hWndGetPtr;
  60. HANDLE m_doWork;
  61. NOTIFYLIST m_notify;
  62. IStream *m_pStream;
  63. UINT_PTR m_hThread;
  64. LOGIN_CREDENTIALS *m_credentials;
  65. LONG m_cRef;
  66. };
  67. #endif __CONNECTTHREAD__