Click here to Skip to main content
15,891,375 members
Articles / Desktop Programming / MFC

Get Hold of System Time without Using Inbuilt Functions (Can be Used with Turbo C++)

Rate me:
Please Sign up or sign in to vote.
1.11/5 (18 votes)
10 Jul 20062 min read 69.3K   625   9  
Getting system timer without using inbuilt system calls
#include <stdafx.h>
#include <conio.h>
#include "BaseTime.h"

CBaseTime::CBaseTime()
{
	_outp(0x70,0x95);
}

CString CBaseTime::GetCurrentTime()
{
	CString curTime;

	_outp(0x70,0x10);
	seconds = _inp(0x71);
	_outp(0x70,0x02);
	minutes = _inp(0x71);
	_outp(0x70,0x04);
	hours = _inp(0x71);
	curTime.Format("%x:%x:%x",hours,minutes,seconds);
	
	return curTime;
	

}

CString CBaseTime::GetCurrentHours()
{
	
	CString retHours;
	_outp(0x70,0x04);
	hours = _inp(0x71);
	retHours.Format("%x",hours);
	return retHours;

}

CString CBaseTime::GetCurrentMinutes()
{
	CString retMins;
		
	minutes = _inp(0x71);
	_outp(0x70,0x02);
	retMins.Format("%x",minutes);
	return retMins;

}

CString CBaseTime::GetCurrentSeconds()
{
	CString retSecs;
	seconds = _inp(0x71);
	_outp(0x70,0x04);
	retSecs.Format("%x",seconds);

	return retSecs;

}

/*UINT CBaseTime::GetCurrentHours()
{
	return (UINT)hours;
}

UINT CBaseTime::GetCurrentMinutes()
{
	return (UINT)minutes;

}
UINT CBaseTime::GetCurrentSeconds()
{

	return (UINT)seconds;
}*/

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.


Written By
Technical Lead
India India
I am a personality from Trivandrum , a green peaceful place in Kerala, South India.
I have been an enthusiast of Windows programming when I started creating simple windows when I learnt VC++ in LCC in Trivandrum. From then on its all about Windows in my flesh and blood.
My career graph moves like this:
1. I started working as a C/C++ programmer in a company in Trivandrum where I learnt the ABCs of Software Industry. I worked with them for about 1 year. I could not contine since I was in contract for 1 year.
2. Then I joined another organization in Trivandrum who gave me challenges to love. They made me mad about VC++ and Windows.
I was mad about Embedded Systems which made me, Myself = Embedded Systems + VC++.
3. Software Engineer in a telecom company in Hyderabad, Andhra Pradesh, S.India.
4. Currently working with a telecom company in Bangalore.
I totally, so, have experience of about 4.5 years.

Comments and Discussions