做一个ping命令,显示ping消息是,要在消息前显示系统的时间,怎么办啊?
有没有具体的函数能实现这个功能啊?
有没有具体的函数能实现这个功能啊?
解决方案 »
- hDll下显示unused CXX0030:Error:expression cannot be evaluated
- VC中...不使用stdAfx.h有什么后果?
- 如果将DEBUG版本的程序拷贝到其它机器上运行?
- 请教高手,怎样调试DeskBand? 难道要装ie 的Debug版本?
- 诚求教 怎么在VC/MFC一个应用程序下集成两种不同的数据源 并进行数据交换?
- 焦点在树的一个结点上时,如何响应回车。谢谢
- 100分请教问题?可以再加分!!感谢!!使用Sybase Client lib或者oracle client lib是如何用vc来编写数据库程序呀?不是用odbc、ado、da
- 诸位一般用什么软件做真彩工具栏?
- 新手方向的迷茫,请各位指教!!
- unsigned char 有没有TCHAR版本?
- 随机数组成的图形,怎么判断波峰和波谷???
- 位图打印问题,快崩溃了!!!
time_t mt; time(&mt);
today=localtime(&mt); sprintf(&s[0],"%d",today->tm_hour);
sprintf(&f[0],"%d",today->tm_min);
sprintf(&m[0],"%d",today->tm_sec);
SYSTEMTIME st;
::GetSystemTime(&st);
struct tm *systime;
time_t now;
now = time((time_t *)NULL);
systime = localtime(&now);
sprintf(t_now,"%d-%d-%d %d:%d:%d",systime->tm_year+1900,systime->tm_mon+1,systime->tm_mday,
systime->tm_hour,systime->tm_min,systime->tm_sec);
CString t = time.Format("%Y-%m-%d %H:%M:%S");
使用API函数:GetLocalTimeThe GetLocalTime function retrieves the current local date and time.
CString sTime,sYear,sMonth,sDay;
SYSTEMTIME CurTime;
GetLocalTime(&CurTime);
sYear.Format("%d年",CurTime.wYear);
sMonth.Format("%d月",CurTime.wMonth);
sDay.Format("%d日",CurTime.wDay);
sTime = sYear+ sMonth + sDay;
// CurTime.wHour
// CurTime.wMinute
// CurTime.wSecond IBM的
AfxMessageBox(sTime);
GetLocalTime(&st);
CString s=t.Format("%H:%M:%S"); //时:分:秒
MessageBox(s);
#include"stdio.h"
main()
{
struct tm when;
time_t now, result;
int days;
time( &now );
when = *localtime(&now);
fprintf("current time is:%s",asctime(&when));
}
得到的结果就是系统时间。