//  Beta release only.
//
//  Copyright(c) Ivyware Pty Ltd 2002-9  (all rights reserved)
//               MELBOURNE, VICTORIA, AUSTRALIA, 3130
//
//  Provided no fee is charged (either by the distributer or user)
//  permission to use, copy, modify, and distribute this software and
//  its documentation for any purpose and without fee is hereby granted,
//  provided that the above copyright notice appear in all copies and
//  that both that copyright notice and this permission notice appear
//  in supporting documentation.
//
//  No waranty or suitablity for purpose is implied.
//
//
//  Definitions and prototypes for Microsoft Kernel32 C++ extensions
//
#pragma once
#include "P2PmsgKERNEL.h"

//
//  Stack based safe CRITICAL_SECTION container
//  NOTES: Allocated CRITICAL_SECTION is managed within the life cycle
//         of this object.
class P2PmsgKERNEL_EXT P2PsafeCS
{
    public:
        P2PsafeCS ( );
        P2PsafeCS ( CRITICAL_SECTION& oCSection);
       ~P2PsafeCS ( );
    public:
      P2PsafeCS&
        operator = ( CRITICAL_SECTION& oCSection );
    private:
        CRITICAL_SECTION *m_pCSection;
};

//
//  Stack based safe HANDLE container
//  NOTES: Allocated HANDLE is managed within the life cycle
//         of this object.
class P2PmsgKERNEL_EXT P2PsafeHANDLE
{
    public:
        P2PsafeHANDLE ( );
        P2PsafeHANDLE ( HANDLE oHandle );
       ~P2PsafeHANDLE ( );
    public:
      P2PsafeHANDLE&
        operator = ( HANDLE oHandle );
        operator HANDLE( );
 
      HANDLE
        Dereference();

    private:
        HANDLE  m_oHandle;
};
