请问delphi中要计算程序运行的时间,怎么办?获取系统时间的函数是什么?

解决方案 »

  1.   

    系统函数:date()当时日期。
    time()当前时间.
      

  2.   

    function GetTickCount: Cardinal;ReturnsCardinal - Number of milliseconds (ticks).
    DescriptionGetTickCount is a Cardinal function used to retrieve the number of milliseconds since the computer was started.
    GetTickCount is often used when calculating the response times for Indy components such as TIdEcho and TIdTime.
    GetTickCount encapsulates the platform-specific calls necessary to provide a high resolution timer for fixed duration events. On the Windows platform, the function used is Windows.GetTickCount. On the Linux platform, GetTickCount uses the library function clock adjusted to thousandths of CLOCKS_PER_SECs.
      

  3.   

    系统函数:date()当时日期。
    time()当前时间.
    GetSystemeTime
    SetsystemTime
      

  4.   

    //    tick : Cardinal;    tick := GetTickCount;
        dosomething;
        tick := GetTickCount - tick;
        MessageBox(0, PChar(time use' + IntToStr(tick) + ' msec'), nil, 0);
      

  5.   

    MSDN:GetTickCountThe GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started. It is limited to the resolution of the system timer. To obtain the system timer resolution, use the GetSystemTimeAdjustment function.
    DWORD GetTickCount(void);Parameters
    This function has no parameters. 
    Return Values
    The return value is the number of milliseconds that have elapsed since the system was started.Res
    The elapsed time is stored as a DWORD value. Therefore, the time will wrap around to zero if the system is run continuously for 49.7 days.If you need a higher resolution timer, use a multimedia timer or a high-resolution timer.Windows NT/2000/XP: To obtain the time elapsed since the computer was started, retrieve the System Up Time counter in the performance data in the registry key HKEY_PERFORMANCE_DATA. The value returned is an 8-byte value. For more information, see Performance Monitoring.Example Code 
    The following example demonstrates how to handle timer wrap around.
    DWORD dwStart = GetTickCount();// Stop if this has taken too long
    if( GetTickCount() - dwStart >= TIMELIMIT )
        Cancel();
    Note that TIMELIMIT is the time interval of interest to the application.
      

  6.   

    gettickcount 
    接近毫秒单位