请问如何设置系统时间?????????

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/1328/1328603.xml?temp=.6154291
      

  2.   

    SYSTEMTIME tm;
    ::GetLocalTime(&tm);
    tm.wYear=1903;
    ::SetLocalTime(&tm);
      

  3.   

    BOOL SetSystemTime(
      CONST SYSTEMTIME *lpSystemTime   // system time
    );具体用法MSDN里有
      

  4.   

    BOOL SetNewTime(WORD hour, WORD minutes)
    {
        SYSTEMTIME st;
        char *pc;    GetSystemTime(&st);       // gets current time
        st.wHour = hour;          // adjusts hours 
        st.wMinute = minutes;     // and minutes
        if (!SetSystemTime(&st))  // sets system time
            return FALSE;
        return TRUE;
    }
      

  5.   

    SYSTEMTIME sysTime;
    sysTime.wYear=2003;
    sysTime.wMonth=1;
    sysTime.wDay=1;
    sysTime.wHour=12;   //时
    sysTime.wMinute=0;  //分
    sysTime.wSecond=0;  //秒
    sysTime.wMilliseconds=0; //毫秒
    SetLocalTime(&sysTime);
    //设置为 2003-1-1 12:00:00:000
      

  6.   

    viod SetTime()
    {
      SYSTEMTIME time;
      time.wYear = ...;
      ...
      time.wMilliseconds =...
      SetSystemTime(time);
    //OK
    }SetSystemTime(CONST SYSTEMTIME *lpSystemTime   // system time
    );
    typedef struct _SYSTEMTIME { 
        WORD wYear; 
        WORD wMonth; 
        WORD wDayOfWeek; 
        WORD wDay; 
        WORD wHour; 
        WORD wMinute; 
        WORD wSecond; 
        WORD wMilliseconds; 
    } SYSTEMTIME, *PSYSTEMTIME;
      

  7.   

    SYSTEMTIME st;
    st.wYear=2003;//今年是2003年
    st.wMonth=12;//这个月是1月
    st.wDay=7;//今天是7号
    st.wHour=12;//现在是12点钟
    st.wMinute=10;//分钟是指向10
    st.wSecond=20;//秒钟指向20
    st.wMilliseconds=0;//精度没有这么高吧
    SetSystemTime(&tt);//现在是2003年1月7日12:10:20:0
      

  8.   

    设置权限:int EnablePriv (char *szPriv)
    {
        HANDLE hToken = 0;

        if (!OpenProcessToken(GetCurrentProcess(),
    TOKEN_ADJUST_PRIVILEGES,
    &hToken))
    {
            printf("OpenProcessToken() failed -> %d", GetLastError());
            return -1;
        }

        TOKEN_PRIVILEGES newPrivs;
        if (!LookupPrivilegeValue (NULL, szPriv,
    &newPrivs.Privileges[0].Luid))
    {
            printf("LookupPrivilegeValue() failed -> %d", GetLastError());
            CloseHandle (hToken);
            return -1;
        }

        newPrivs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
        newPrivs.PrivilegeCount = 1;    if (!AdjustTokenPrivileges(hToken, FALSE, &newPrivs, 0, NULL, NULL))
    {
            printf("AdjustTokenPrivileges() failed -> %d", GetLastError());
            CloseHandle (hToken);
            return -1;
        }    CloseHandle (hToken);
        return 0;
    }SYSTEMTIME sysTime;
    GetLocalTime(&sysTime);
    EnablePriv(SE_SYSTEMTIME_NAME); //win2000下设置权限
    sysTime.wYear = 2001;           //改年为2001
    SetLocalTime(&sysTime);