Click here to Skip to main content
13,596,891 members
Click here to Skip to main content

Stats

406.7K views
12.2K downloads
279 bookmarked
Posted 10 May 2000
Licenced

The Win32 Foundation Classes (WFC) - Version 45

, 16 May 2000
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
HTML
html.dsw
html.dsp
sample
Sample
ADO2XML
ADO2XML.dsp
ADO2XML.dsw
ChangeServiceConfiguration
ChangeServiceConfiguration.dsp
ChangeServiceConfiguration.dsw
ClockSync
ClockSync.dsp
ClockSync.dsw
Counter
Crypto
Crypto.dsp
Crypto.dsw
CScript
CScript.dsp
CScript.dsw
Data
Receiver
Receiver.dsp
Receiver.dsw
Sender
Sender.dsp
Sender.dsw
DeMangle
DeMangle.dsp
DeMangle.dsw
DriverMover
DriverMover.dsp
DriverMover.dsw
res
DriverMover.ico
DumpEventLog
EnableRASLogging
EventPager
EventPager.dsp
EventPager.dsw
MAKEMC.CMD
messages.mc
GetWebPage
GetWebPage.dsp
GetWebPage.dsw
HTML
html.dsp
html.dsw
KillDoc
KillDoc.dsp
KillDoc.dsw
LastEvent
LastEvent.dsp
LastEvent.dsw
Listen
Listen.dsp
Listen.dsw
ListProcesses
ListProcesses.dsp
ListProcesses.dsw
MAKEMC.CMD
Map2Def
Map2Def.dsp
Map2Def.dsw
Microphone
Microphone.dsp
Microphone.dsw
MIME2HTML
Debug
MIME2HTML.dsp
MIME2HTML.dsw
PasswordFilter
DLL
PasswordDLL.dsp
PasswordDLL.dsw
PasswordFilter.dsp
PasswordFilter.dsw
Ping
Ping.dsp
Ping.dsw
Pinger
MAKEMC.CMD
MESSAGES.MC
Pinger.dsp
Pinger.dsw
PINGER.RC
Pinger.ver
RasAdmin
RasAdmin.dsp
RasAdmin.dsw
Serial
Serial.dsp
Serial.dsw
SerialTest
Normal
Receiver
Receiver.dsp
Receiver.dsw
Sender
Sender.dsp
Sender.dsw
Service
Service.dsp
Service.dsw
SkyPage
SKYPAGE.CPP
SkyPage.dsp
SkyPage.dsw
SprintSpectrum
SprintSpectrum.dsp
SprintSpectrum.dsw
Squiggle
TortureXML
TortureXML.dsp
TortureXML.dsw
USNOTime
USNOTime.dsp
USNOTime.dsw
WatchDog
MAKEMC.CMD
messages.mc
WatchDog.dsp
WatchDog.dsw
WatchDog.ver
Wfc2Html
Wfc2Html.dsp
Wfc2Html.dsw
WinPage
res
WinPage.ico
WinPage.dsp
WinPage.dsw
XML
Debug
XML.DSP
XML.dsw
XMLCheck
Debug
XML
XMLCheck.dsp
XMLCheck.dsw
XMLExplorer
res
bitmap1.bmp
CXMLExplorerDocument.ico
Toolbar.bmp
XMLExplorer.ico
XMLExplorer.dsp
XMLExplorer.dsw
XMLUser
XMLUser.dsp
XMLUser.dsw
TEST
Grid
MESSAGES.MC
Pipe
pipe.CPP
Server.CPP
REPERR.CPP
TCLZFile.CPP
TCNet.CPP
TCNetCon.CPP
TCNetFil.CPP
TCNetshs.CPP
TCNetUSR.CPP
TCRAS.CPP
TCRASPORT.CPP
TCREG.CPP
TCSess.CPP
TCSrvr.CPP
TCSvcMgr.CPP
TEST.CPP
TEST.dsp
TEST.dsw
TEST.H
TEST.MAK
test_CNetwork.CPP
TEVNTLOG.CPP
TURL.CPP
XMLConformanceTest
XMLConformanceTest.dsp
XMLConformanceTest.dsw
wfc
BACKUP.CMD
HTML
web
CLASSES.HTM
HOMEPAGE.HTM
pax.HTM
TIMEBEG.HTM
TITLE.HTM
WFC.HTM
INCLUDE
CEventLogRecord.HPP
CEVNTLOG.HPP
CNMPIPE.HPP
CRAS.HPP
CRASADM.HPP
CRASPORT.HPP
CREGISTY.HPP
CUNC.HPP
CURL.HPP
DCB.HPP
LSOCKETS.HPP
LZFILE.HPP
OVRLPD.HPP
SOCKETS.HPP
TSOCKETS.HPP
WFC.H
LIB
WFC.dsp
WFC.dsw
PAXIT.CMD
SRC
CEventLogRecord.CPP
CEVNTLOG.CPP
CRAS.CPP
CRASADM.CPP
CUNC.CPP
CURL.CPP
DCB.CPP
LSOCKETS.CPP
Modem.CPP
NAMDPIPE.CPP
OVRLPD.CPP
PortInformation.CPP
RASCP.CPP
RASNBPCP.CPP
RASPORT.CPP
RASPSTAT.CPP
REGISTRY.CPP
RemoteAccessServicePort.CPP
Serial.CPP
SOCKETS.CPP
TALKSOCK.CPP
#if ! defined( TIME_EX_CLASS_HEADER_FILE )

#define TIME_EX_CLASS_HEADER_FILE

class CTimeSpan
{
   protected:

      time_t m_NumberOfSeconds;

   public:

      inline  CTimeSpan() { m_NumberOfSeconds = 0; }
      inline  CTimeSpan( unsigned long number_of_seconds ) { m_NumberOfSeconds = number_of_seconds; }
      inline  CTimeSpan( unsigned long days, unsigned long hours, unsigned long minutes, unsigned long number_of_seconds )
      {
         m_NumberOfSeconds  = number_of_seconds;
         m_NumberOfSeconds += ( minutes * 60L );
         m_NumberOfSeconds += ( 60L * 60L * hours );
         m_NumberOfSeconds += ( 24L * 60L * 60L * days );
      }
      inline CTimeSpan( const CTimeSpan& source ) { m_NumberOfSeconds = source.m_NumberOfSeconds; }
      inline ~CTimeSpan() { m_NumberOfSeconds = 0; }

      inline long   GetTotalHours( void ) const { return( m_NumberOfSeconds / 3600L ); }
      inline long   GetTotalMinutes( void ) const { return( m_NumberOfSeconds / 60L ); }
      inline time_t GetTotalSeconds( void ) const { return( m_NumberOfSeconds ); }
      inline long   GetDays( void ) const { return( m_NumberOfSeconds / 86400L ); }
      inline long   GetHours( void ) const { return( GetTotalHours() - ( GetDays() * 24L ) ); }
      inline long   GetMinutes( void ) const { return( GetTotalMinutes() - ( GetTotalHours() * 60L ) ); }
      inline long   GetSeconds( void ) const { return( GetTotalSeconds() - ( GetTotalMinutes() * 60L ) ); }
      inline CTimeSpan operator-( const CTimeSpan& source ) const { return( CTimeSpan( m_NumberOfSeconds - source.m_NumberOfSeconds ) ); }
      inline CTimeSpan operator+( const CTimeSpan& source ) const { return( CTimeSpan( m_NumberOfSeconds + source.m_NumberOfSeconds ) ); }
      inline const CTimeSpan& operator+=( const CTimeSpan& source ) { m_NumberOfSeconds += source.m_NumberOfSeconds; return( *this ); }
      inline const CTimeSpan& operator-=( const CTimeSpan& source ) { m_NumberOfSeconds -= source.m_NumberOfSeconds; return( *this ); }
      inline BOOL operator == ( const CTimeSpan& source ) const { return( m_NumberOfSeconds == source.m_NumberOfSeconds ); }
      inline BOOL operator != ( const CTimeSpan& source ) const { return( m_NumberOfSeconds != source.m_NumberOfSeconds ); }
      inline BOOL operator < ( const CTimeSpan& source ) const  { return( m_NumberOfSeconds <  source.m_NumberOfSeconds ); }
      inline BOOL operator > ( const CTimeSpan& source ) const  { return( m_NumberOfSeconds >  source.m_NumberOfSeconds ); }
      inline BOOL operator <= ( const CTimeSpan& source ) const { return( m_NumberOfSeconds <= source.m_NumberOfSeconds ); }
      inline BOOL operator >= ( const CTimeSpan& source ) const { return( m_NumberOfSeconds >= source.m_NumberOfSeconds ); }

      CString Format( LPCTSTR format_string ) const;
};

class CTimeEx
{
   protected:

      time_t m_Time;

      time_t m_Make_time_t( const struct tm * time_p );

   public:

      // Construction

      CTimeEx();
      CTimeEx( const CTimeEx&    source );
      CTimeEx( const CTimeEx *   source );
      CTimeEx( const time_t      source );
      CTimeEx( const struct tm * source );
      CTimeEx( const struct tm&  source );
      CTimeEx( int year, int month, int day, int hour, int minute, int second, int daylight_savings_time = -1 );
     ~CTimeEx();

      // Methods

      static void GetCurrentTheTime( CTimeEx& source );
      static void GreenwichMeanTime( const time_t * address_of_a_time_t, struct tm * address_of_a_tm_structure );

      int    Compare( const CTimeEx& source ) const;
      void   Copy( const CTimeEx&    source );
      void   Copy( const CTimeEx *   source );
      void   Copy( const time_t      source );
      void   Copy( const struct tm * source );
      void   Copy( const struct tm&  source );
      void   CopyModifiedJulianDate( double source );
      void   CopyTo( time_t&    destination ) const;
      void   CopyTo( struct tm& destination ) const;
      void   CopyTo( CString& iso_8601_date ) const;
      void   Empty( void );
      CString Format( LPCTSTR format_string ) const; // same as strftime
      int    GetDay( void ) const;
      int    GetDayOfWeek( void ) const;
      int    GetDayOfYear( void ) const;
      int    GetHour( void ) const;
      int    GetMinute( void ) const;
      int    GetMonth( void ) const;
      int    GetSecond( void ) const;
      void   GetTime( struct tm& time_structure ) const;
      time_t GetTotalSeconds( void ) const;
      int    GetYear( void ) const;
      void   Set( const CString& iso_8601_date );
      void   Set( int year, int month, int day, int hour, int minute, int second, int daylight_savings_time = -1 );

      // Operators

      inline                 operator time_t     ( void                     ) const { return( m_Time ); };
      inline       CTimeEx&  operator =          ( const CTimeEx&    source )       { Copy( source ); return( *this ); };
      inline       CTimeEx&  operator =          ( const time_t      source )       { Copy( source ); return( *this ); };
      inline       CTimeEx&  operator =          ( const struct tm&  source )       { Copy( source ); return( *this ); };
      inline       BOOL      operator ==         ( const CTimeEx&    source ) const { return( ( Compare( source ) == 0   ) ? TRUE  : FALSE ); };
      inline       BOOL      operator !=         ( const CTimeEx&    source ) const { return( ( Compare( source ) == 0   ) ? FALSE : TRUE  ); };
      inline       BOOL      operator >=         ( const CTimeEx&    source ) const { return( ( Compare( source ) > (-1) ) ? TRUE  : FALSE ); };
      inline       BOOL      operator <=         ( const CTimeEx&    source ) const { return( ( Compare( source ) < 1    ) ? TRUE  : FALSE ); };
      inline       BOOL      operator >          ( const CTimeEx&    source ) const { return( ( Compare( source ) > 0    ) ? TRUE  : FALSE ); };
      inline       BOOL      operator <          ( const CTimeEx&    source ) const { return( ( Compare( source ) < 0    ) ? TRUE  : FALSE ); };
      inline       CTimeSpan operator -          ( const CTimeEx&    source ) const { return( CTimeSpan( m_Time - source.m_Time ) ); };
      inline       CTimeEx   operator -          ( const CTimeSpan&  source ) const { return( CTimeEx( m_Time - source.GetTotalSeconds() ) ); };
      inline       CTimeEx   operator +          ( const CTimeSpan&  source ) const { return( CTimeEx( m_Time + source.GetTotalSeconds() ) ); };
      inline const CTimeEx&  operator +=         ( const CTimeSpan&  source )       { m_Time += source.GetTotalSeconds(); return( *this ); };
      inline const CTimeEx&  operator -=         ( const CTimeSpan&  source )       { m_Time -= source.GetTotalSeconds(); return( *this ); };
};

class CTime
{
   protected:

      CTimeEx m_Time;

   public:

      inline CTime(){};
      inline CTime( time_t the_time ) : m_Time( the_time ) {};
      inline CTime( int year, int month, int day, int hour, int minute, int second, int daylight_savings_time = -1 )
      {
         m_Time = CTimeEx( year, month, day, hour, minute, second, daylight_savings_time );
      }

      inline ~CTime() {};

      static CTime PASCAL GetCurrentTime() { CTimeEx the_time; CTimeEx::GetCurrentTheTime( the_time ); return( CTime( (time_t) the_time ) ); }

      // Snap all of the calls to CTimeEx

      inline CString Format( LPCTSTR format_string ) const { return( m_Time.Format( format_string ) ); }
      inline int GetDay(       void ) const { return( m_Time.GetDay()       ); }
      inline int GetDayOfWeek( void ) const { return( m_Time.GetDayOfWeek() ); }
      inline int GetHour(      void ) const { return( m_Time.GetHour()      ); }
      inline int GetMinute(    void ) const { return( m_Time.GetMinute()    ); }
      inline int GetMonth(     void ) const { return( m_Time.GetMonth()     ); }
      inline int GetSecond(    void ) const { return( m_Time.GetSecond()    ); }
      inline int GetYear(      void ) const { return( m_Time.GetYear()      ); }

      inline                 operator time_t     ( void                     ) const { return( m_Time.operator time_t() ); }
      inline       CTime&    operator =          ( const CTime&      source )       { m_Time.Copy( source.m_Time ); return( *this ); }
      inline       CTime&    operator =          ( const time_t      source )       { m_Time.Copy( source        ); return( *this ); }
      inline       CTime&    operator =          ( const struct tm&  source )       { m_Time.Copy( source        ); return( *this ); }
      inline       BOOL      operator ==         ( const CTime&      source ) const { return( m_Time.operator==( source.m_Time ) ); }
      inline       BOOL      operator !=         ( const CTime&      source ) const { return( m_Time.operator!=( source.m_Time ) ); }
      inline       BOOL      operator >=         ( const CTime&      source ) const { return( m_Time.operator>=( source.m_Time ) ); }
      inline       BOOL      operator <=         ( const CTime&      source ) const { return( m_Time.operator<=( source.m_Time ) ); }
      inline       BOOL      operator >          ( const CTime&      source ) const { return( m_Time.operator> ( source.m_Time ) ); }
      inline       BOOL      operator <          ( const CTime&      source ) const { return( m_Time.operator< ( source.m_Time ) ); }
      inline       CTimeSpan operator -          ( const CTime&      source ) const { return( m_Time.operator- ( source.m_Time ) ); }
      inline       CTime     operator -          ( const CTimeSpan&  source ) const { return( m_Time.operator- ( source        ) ); }
      inline       CTime     operator +          ( const CTimeSpan&  source ) const { return( m_Time.operator+ ( source        ) ); }
      inline const CTime&    operator +=         ( const CTimeSpan&  source )       { m_Time += source; return( *this ); }
      inline const CTime&    operator -=         ( const CTimeSpan&  source )       { m_Time -= source; return( *this ); }
};

#endif // TIME_EX_CLASS_HEADER_FILE

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

Share

About the Author

Sam Blackburn
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/.

You may also be interested in...

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180621.3 | Last Updated 17 May 2000
Article Copyright 2000 by Sam Blackburn
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid