need help in C++

M

MK1983

Guest
hmm.... any 1 noes how to use C++ to Extract time/date from the taskbar??
 
erm... but i duno how... got ani webby tats shows any examples??
 
Here is an example of how to use time format in Windos.

#include <time.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/timeb.h>
#include <string.h>

void main()
{
char tmpbuf[128], ampm[] = "AM";
time_t ltime;
struct _timeb tstruct;
struct tm *today, *gmt, xmas = { 0, 0, 12, 25, 11, 93 };

/* Set time zone from TZ environment variable. If TZ is not set,
* the operating system is queried to obtain the default value
* for the variable.
*/
_tzset();

/* Display operating system-style date and time. */
_strtime( tmpbuf );
printf( "OS time:\t\t\t\t%s\n", tmpbuf );
_strdate( tmpbuf );
printf( "OS date:\t\t\t\t%s\n", tmpbuf );

/* Get UNIX-style time and display as number and string. */
time( &ltime );
printf( "Time in seconds since UTC 1/1/70:\t%ld\n", ltime );
printf( "UNIX time and date:\t\t\t%s", ctime( &ltime ) );

/* Display UTC. */
gmt = gmtime( &ltime );
printf( "Coordinated universal time:\t\t%s", asctime( gmt ) );

/* Convert to time structure and adjust for PM if necessary. */
today = localtime( &ltime );
if( today->tm_hour > 12 )
{
strcpy( ampm, "PM" );
today->tm_hour -= 12;
}
if( today->tm_hour == 0 ) /* Adjust if midnight hour. */
today->tm_hour = 12;

/* Note how pointer addition is used to skip the first 11
* characters and printf is used to trim off terminating
* characters.
*/
printf( "12-hour time:\t\t\t\t%.8s %s\n",
asctime( today ) + 11, ampm );

/* Print additional time information. */
_ftime( &tstruct );
printf( "Plus milliseconds:\t\t\t%u\n", tstruct.millitm );
printf( "Zone difference in seconds from UTC:\t%u\n",
tstruct.timezone );
printf( "Time zone name:\t\t\t\t%s\n", _tzname[0] );
printf( "Daylight savings:\t\t\t%s\n",
tstruct.dstflag ? "YES" : "NO" );

/* Make time for noon on Christmas, 1993. */
if( mktime( &xmas ) != (time_t)-1 )
printf( "Christmas\t\t\t\t%s\n", asctime( &xmas ) );

/* Use time structure to build a customized time string. */
today = localtime( &ltime );

/* Use strftime to build a customized time string. */
strftime( tmpbuf, 128,
"Today is %A, day %d of %B in the year %Y.\n", today );
printf( tmpbuf );
}
 
From MSDN.

If you have any other questions, please ask.
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back