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.

150 lines
3.5 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ScriptResource.h
  7. //
  8. // Description:
  9. // CScriptResource class header file.
  10. //
  11. // Maintained By:
  12. // gpease 14-DEC-1999
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #pragma once
  16. //
  17. // Forward declarations
  18. //
  19. class CScriptResource;
  20. typedef enum _EMESSAGE {
  21. msgUNKNOWN = 0,
  22. msgOPEN,
  23. msgCLOSE,
  24. msgONLINE,
  25. msgOFFLINE,
  26. msgTERMINATE,
  27. msgLOOKSALIVE,
  28. msgISALIVE,
  29. msgDIE,
  30. msgMAX
  31. } EMESSAGE;
  32. //
  33. // CreateInstance
  34. //
  35. CScriptResource *
  36. CScriptResource_CreateInstance(
  37. LPCWSTR pszNameIn,
  38. HKEY hkeyIn,
  39. RESOURCE_HANDLE hResourceIn
  40. );
  41. //
  42. // Class CScriptResource
  43. //
  44. class
  45. CScriptResource :
  46. public IUnknown
  47. {
  48. private: // data
  49. LONG m_cRef;
  50. LPWSTR m_pszName;
  51. LPWSTR m_pszScriptFilePath;
  52. LPWSTR m_pszScriptEngine;
  53. HKEY m_hkeyParams;
  54. IActiveScriptSite * m_pass;
  55. IDispatch * m_pidm;
  56. IActiveScriptParse * m_pasp;
  57. IActiveScript * m_pas;
  58. HANDLE m_hThread;
  59. DWORD m_dwThreadId;
  60. HANDLE m_hEventWait;
  61. HANDLE m_hEventDone;
  62. LONG m_lockSerialize;
  63. // Task stuff
  64. EMESSAGE m_msg; // task to do.
  65. HRESULT m_hr; // result of doing m_msg.
  66. // the following don't need to be freed, closed or released.
  67. RESOURCE_HANDLE m_hResource;
  68. DISPID m_dispidOpen;
  69. DISPID m_dispidClose;
  70. DISPID m_dispidOnline;
  71. DISPID m_dispidOffline;
  72. DISPID m_dispidTerminate;
  73. DISPID m_dispidLooksAlive;
  74. DISPID m_dispidIsAlive;
  75. BOOL m_fLastLooksAlive;
  76. private: // methods
  77. CScriptResource( );
  78. ~CScriptResource( );
  79. HRESULT
  80. Init( LPCWSTR pszNameIn,
  81. HKEY hkeyIn,
  82. RESOURCE_HANDLE hResourceIn
  83. );
  84. LPWSTR
  85. MakeScriptEngineAssociation(
  86. IN LPCWSTR pszScriptFileName
  87. );
  88. HRESULT
  89. DoConnect( IN LPWSTR szScriptFilePath = NULL );
  90. void
  91. DoDisconnect( );
  92. static DWORD WINAPI
  93. S_ThreadProc( LPVOID pParam );
  94. STDMETHOD(LogError)( HRESULT hrIn );
  95. STDMETHOD(LogScriptError)( EXCEPINFO ei );
  96. HRESULT
  97. OnOpen( );
  98. HRESULT
  99. OnClose( );
  100. HRESULT
  101. OnOnline( );
  102. HRESULT
  103. OnOffline( );
  104. HRESULT
  105. OnTerminate( );
  106. HRESULT
  107. OnLooksAlive( );
  108. HRESULT
  109. OnIsAlive( );
  110. HRESULT
  111. WaitForMessageToComplete( EMESSAGE msgIn );
  112. public: // methods
  113. friend CScriptResource *
  114. CScriptResource_CreateInstance( LPCWSTR pszNameIn,
  115. HKEY hkeyIn,
  116. RESOURCE_HANDLE hResourceIn
  117. );
  118. // IUnknown
  119. STDMETHOD(QueryInterface)( REFIID riid, LPVOID *ppv );
  120. STDMETHOD_(ULONG, AddRef)(void);
  121. STDMETHOD_(ULONG, Release)(void);
  122. // Publics
  123. STDMETHOD(Open)( );
  124. STDMETHOD(Close)( );
  125. STDMETHOD(Online)( );
  126. STDMETHOD(Offline)( );
  127. STDMETHOD(Terminate)( );
  128. STDMETHOD(LooksAlive)( );
  129. STDMETHOD(IsAlive)( );
  130. }; // class CScriptResource