Click here to Skip to main content
15,892,059 members
Articles / Desktop Programming / MFC

The Win32 Foundation Classes (WFC) - Version 45

Rate me:
Please Sign up or sign in to vote.
4.93/5 (40 votes)
16 May 2000 469.5K   12.7K   280  
The Win32 Foundation Classes (WFC) are a library of C++ classes that extend Microsoft Foundation Classes (MFC) beyond mere GUI applications, and provide extensive support for system and NT specific applications
#include <wfc.h>
#pragma hdrstop

/*
** Author: Samuel R. Blackburn
** Internet: wfc@pobox.com
**
** You can use it any way you like as long as you don't try to sell it.
**
** Any attempt to sell WFC in source code form must have the permission
** of the original author. You can produce commercial executables with
** WFC but you can't sell WFC.
**
** Copyright, 2000, Samuel R. Blackburn
**
** $Workfile: CCriticalSection.cpp $
** $Revision: 6 $
** $Modtime: 1/04/00 5:09a $
*/

// Change the next line to a 1 if you want your own CCriticalSection

#if 0 

#if defined( _DEBUG )
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#if defined( _DEBUG )
#define new DEBUG_NEW
#endif

CCriticalSection::CCriticalSection()
{
   WFCLTRACEINIT( "CCriticalSection::CCriticalSection()" );
   WFCTRACEVAL( "pointer is ", (VOID *) this );

   ::InitializeCriticalSection( &m_CriticalSection );
}

CCriticalSection::~CCriticalSection()
{
   WFCLTRACEINIT( "CCriticalSection::~CCriticalSection()" );
   WFCTRACEVAL( "pointer is ", (VOID *) this );

   ::DeleteCriticalSection( &m_CriticalSection );
}

void CCriticalSection::Enter( void )
{
   WFCLTRACEINIT( "CCriticalSection::Enter()" );
   ::EnterCriticalSection( &m_CriticalSection );
}

void CCriticalSection::Exit( void )
{
   WFCLTRACEINIT( "CCriticalSection::Exit()" );
   ::LeaveCriticalSection( &m_CriticalSection );
}

#if( _WIN32_WINNT >= 0x0400 )

BOOL CCriticalSection::TryToEnter( void )
{
   WFCLTRACEINIT( "CCriticalSection::TryToEnter()" );

   BOOL return_value = FALSE;

   return_value = ::TryEnterCriticalSection( &m_CriticalSection );

   return( return_value );
}

#endif // _WIN32_WINNT

#endif // 0

#if 0
<WFC_DOCUMENTATION>
<HTML>
<HEAD>
<TITLE>WFC - CCriticalSection</TITLE>
<META name="keywords" content="WFC, MFC extension library, freeware class library, Win32">
<META name="description" content="Obsolete encapsulation of critical sections.">
</HEAD>
<BODY>
<H1>CCriticalSection</H1>
$Revision: 6 $<BR>
<HR>
<H2>Description</H2>
This class allows you to play with critical sections. It is
obsolete since Microsoft added a CCriticalSection
class to MFC.
<H2>Data Members</H2>
None.
<H2>Methods</H2>
<DL COMPACT>
<DT><PRE>void <B>Enter</B>( void )</PRE><DD>
Blocks execution until the critical section can be entered.
<DT><PRE>void <B>Exit</B>( void )</PRE><DD>
Allows other threads to now enter the critical section.
<DT><PRE>BOOL <B>TryToEnter</B>( void )</PRE><DD>
Will attempt to enter the critical section. If is succeeds
then TRUE will be returned. If it cannot enter the critical
section the FALSE is immediately returned, no blocking takes
place.
</DL>
<H2>Example</H2>
<PRE><CODE>Sorry.</CODE></PRE>
<H2>API's Used</H2>
<DL COMPACT>
<LI>DeleteCriticalSection
<LI>EnterCriticalSection
<LI>InitializeCriticalSection
<LI>LeaveCriticalSection
<LI>TryEnterCriticalSection
</DL>
<I>Copyright, 2000, Samuel R. Blackburn</I><BR>
$Workfile: CCriticalSection.cpp $<BR>
$Modtime: 1/04/00 5:09a $
</BODY>
</HTML>
</WFC_DOCUMENTATION>
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
I'm just a simple little NT programmer. Most of the work I do is remote controlling equipment in real time. I started out using Windows 3.0. Then came 3.1 and then NT. I started using NT but unfortunately, Microsoft didn't. I started using MFC but unfortunately, Microsoft didn't (and still doesn't) put any real support for NT into MFC so I wrote a bunch of C++ classes to make my life easier. Like all class libraries, mine grew. Now I'm giving it away, I call it Win32 Foundation Classes.

Check out Sam's homepage at www.SamBlackburn.com/wfc/.

Comments and Discussions