Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

CHandle Class

This class provides methods for creating and using a handle object.

class CHandle

Name

Description

CHandle::CHandle

The constructor.

CHandle::~CHandle

The destructor.

Name

Description

CHandle::Attach

Call this method to attach the CHandle object to an existing handle.

CHandle::Close

Call this method to close a CHandle object.

CHandle::Detach

Call this method to detach a handle from a CHandle object.

Name

Description

CHandle::operator HANDLE

Returns the value of the stored handle.

CHandle::operator =

Assignment operator.

Name

Description

CHandle::m_h

The member variable that stores the handle.

A CHandle object can be used whenever a handle is required: the main difference is that the CHandle object will automatically be deleted.

Note Note

Some API functions will use NULL as an empty or invalid handle, while others use INVALID_HANDLE_VALUE. CHandle only uses NULL and will treat INVALID_HANDLE_VALUE as a real handle. If you call an API which can return INVALID_HANDLE_VALUE, you should check for this value before calling CHandle::Attach or passing it to the CHandle constructor, and instead pass NULL.

Header: atlbase.h

Show:
© 2015 Microsoft