谁能告诉我修改机器时间的函数?

解决方案 »

  1.   

    SetSystemTimeThe SetSystemTime function sets the current system time and date. The system time is expressed in Coordinated Universal Time (UTC).
    BOOL SetSystemTime(
      const SYSTEMTIME* lpSystemTime
    );Parameters
    lpSystemTime 
    [in] Pointer to a SYSTEMTIME structure that contains the current system date and time. 
    The wDayOfWeek member of the SYSTEMTIME structure is ignored.Return Values
    If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError.Res
    The SetSystemTime function enables the SE_SYSTEMTIME_NAME privilege before changing the system time. This privilege is disabled by default. For more information, see Running with Special Privileges.Example Code 
    For an example, see Setting the System Time.Requirements
    Client: Included in Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, and Windows 95.
    Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server.
    Header: Declared in Winbase.h; include Windows.h.
    Library: Use Kernel32.lib.
      

  2.   

    SYSTEMTIMEThe SYSTEMTIME structure represents a date and time using individual members for the month, day, year, weekday, hour, minute, second, and millisecond.
    typedef struct _SYSTEMTIME {  WORD wYear;  WORD wMonth;  WORD wDayOfWeek;  WORD wDay;  WORD wHour;  WORD wMinute;  WORD wSecond;  WORD wMilliseconds;
    } SYSTEMTIME, *PSYSTEMTIME;
    Members
    wYear 
    Current year. The year must be greater than 1601. Windows Server 2003, Windows XP:  The year cannot be greater than 30827.
    wMonth 
    Current month; January = 1, February = 2, and so on. 
    wDayOfWeek 
    Current day of the week; Sunday = 0, Monday = 1, and so on. 
    wDay 
    Current day of the month. 
    wHour 
    Current hour. 
    wMinute 
    Current minute. 
    wSecond 
    Current second. 
    wMilliseconds 
    Current millisecond. 
    Res
    It is not recommended that you add and subtract values from the SYSTEMTIME structure to obtain relative times. Instead, you should
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      S: SYSTEMTIME;
    begin
      DateTimeToSystemTime(Now,S);
      SetLocalTime(S);
    end;
      

  4.   

    var
      S: SYSTEMTIME;
    begin
      DateTimeToSystemTime(strtodatetime('2003-4-29 15:14:32'),S);
      SetLocalTime(S);
    end;
      

  5.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      S: SYSTEMTIME;
    begin  DateTimeToSystemTime(datetimepicker1.DateTime,S);
      SetLocalTime(S);
    end;
    procedure TForm1.Timer1Timer(Sender: TObject);
    var
    systemtime:Tsystemtime;
    begin
      getlocaltime(systemtime);
      statusbar1.Panels[0].Text:=formatdatetime('yyyy-mm-dd',systemtimetodatetime(systemtime));
    end;end.