把握命运,追逐梦想

对自己所做的事要有兴趣,同时还要能够坚持不懈

统计

留言簿(1)

阅读排行榜

评论排行榜

一个time的例子 SYSTEMTIME

// mfctime.cpp : 定义控制台应用程序的入口点。
//

#include 
"stdafx.h"
#include 
"mfctime.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// 唯一的应用程序对象

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
    
int nRetCode = 0;

    
// 初始化 MFC 并在失败时显示错误
    if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
    
{
        
// TODO: 更改错误代码以符合您的需要
        _tprintf(_T("错误: MFC 初始化失败\n"));
        nRetCode 
= 1;
    }

    
else
    
{
        
// TODO: 在此处为应用程序的行为编写代码。
        time_t t;
        time(
&t);
        tm 
*newtime;
        newtime 
= localtime(&t);

        printf(
"%s",asctime(newtime));


        
//C++写法
        SYSTEMTIME tt;
        GetLocalTime(
&tt);

        CString str;
        str.Format(_T(
"%u/%u/%u  %u:%u:%u:%u"),
            tt.wYear, tt.wMonth, tt.wDay,
            tt.wHour, tt.wMinute, tt.wSecond,
            tt.wMilliseconds);

        LPTSTR lpsz 
= new TCHAR[str.GetLength()+1];
        _tcscpy(lpsz, str);
        wprintf(L
"%s",lpsz);


    }


    
return nRetCode;
}

posted on 2009-07-29 17:43 把握命运 阅读(1372) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理