系统时间可以设置为:例如,09:02:06 也可以设置为:9:2:6.如何得到当前用户设置的前面一种格式还是后面一种?

解决方案 »

  1.   

    GetTimeFormat() 是根据自己指定格式获取当前时间
      

  2.   

    在资源的字符串中添加一个ID_TIME,标题为00:00:00,并在static UINT indicators[]中添加ID_TIME, 在int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)函数中添加SetTimer(1,500,NULL); 
       在CMainFrame中增加void CMainFrame::OnTimer(UINT nIDEvent) ,并在其中添加代码  
       if(nIDEvent==  )//写上ID_TIME在static UINT indicators[]中的位置标示
         {CTime t=CTime::GetCurrentTime();
      CString str=t.Format("%H:%M:%S");
      m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(
                          ID_TIME),str);
         }
      就可在状态栏中显示出如09:02:06格式的系统时间!!
      

  3.   

    SYSTEMTIME tm;
    GetLocalTime(&tm);
    CString str;
    str.Format("%d:%d:%d",tm.Hour,tm.Minute,tm.Second);