home *** CD-ROM | disk | FTP | other *** search
/ Media Share 13 / mediashare_13.zip / mediashare_13 / ZIPPED / PROGRAM / WTJ9403.ZIP / WILDASS / SOURCE / TASKS.H < prev    next >
C/C++ Source or Header  |  1993-08-13  |  2KB  |  98 lines

  1. // taks.h
  2. //
  3. // class interface to the classes
  4. //  CTask
  5. //  CTaskList
  6. //  which encapsulates the toolhelps TASKENTRY and other structures
  7. //
  8. // update: 1.00 06-08-93 tw
  9.  
  10. #ifndef _INC_TASKH
  11. #define _INC_TASKH
  12.  
  13. #include <toolhelp.h>
  14.  
  15. class CTask : public CObject
  16. private:
  17.    TASKENTRY   m_te;         // an SDK taskentry
  18.    CString     m_strExePath; // exepath from this tasks moduleentry
  19.    // list of all top-level non-owned windows of this task
  20.    // -> send them a WM_CLOSE 
  21.    static BOOL CALLBACK __export EnumTaskWndProcCloseApp( HWND hWnd, LPARAM lParam );
  22.     
  23. public:
  24.    CTask( TASKENTRY * pTE );
  25.  
  26.    // return the taskhandle   
  27.    HTASK HTask() const;    
  28.    operator HTASK() const;    
  29.    
  30.    // return the instance handle      
  31.    HINSTANCE HInstance() const;
  32.    operator HINSTANCE() const;
  33.    
  34.    // retrieve the module handle
  35.    HMODULE HModule() const;
  36.    // operator HMODULE() const;  
  37.    // wont work as HINSTANCE==HMODULE 
  38.    
  39.    // retrieve the exes name and the modules name
  40.    // associated to this task
  41.    const char* ExeName() const;
  42.    const char* ModuleName() const;
  43.    
  44.    void DieHard() const;  // kill this task  (abprupt termination)
  45.    void Die() const;      // close this task (clean termination)
  46.             
  47.    static BOOL IsTask( CTask * );  // is this a valid task
  48.    static BOOL IsTask( HTASK );
  49.    BOOL IsTask() const;
  50.    
  51. #ifdef _DEBUG
  52.    void Dump() const;
  53.    void AssertValid() const;
  54. #endif
  55.  
  56.    // retrieving details
  57.    HTASK HParent() const;
  58.    WORD  Events() const;
  59.    WORD  Usage() const;
  60.    
  61.    
  62. };
  63.  
  64. class CTaskList : public CObList
  65. public:
  66.    CTaskList();
  67.    ~CTaskList();
  68.         
  69.    // rebuild the list
  70.    void Rebuild();
  71.    
  72.    // clear the list
  73.    void Clear();
  74.         
  75.    void CloseDirty( CTask * pTask );  // kill this task
  76.    void CloseClean( CTask * pTask );  // close this task
  77.        
  78.    // avoid casts in usage
  79.    CTask*& GetNext( POSITION& rPos );
  80.    CTask* GetNext( POSITION& rPos ) const;
  81.    CTask*& GetAt( POSITION pos );
  82.    CTask* GetAt( POSITION pos ) const;
  83.        
  84.    // remove a CTask from the list using a pointer to it
  85.    void Remove( CTask * );    
  86.       
  87. #ifdef _DEBUG
  88.    void Dump() const;
  89. #endif   
  90.    
  91. };
  92.  
  93.  
  94. #endif  // _INCTASKH
  95.  
  96.