static DWORD  dwTickStart = 0;
void SetStatusStatus(void){  char        szStatusStatusLine[MAX_BUF_MEDIUM];  char        szCurrentStatusInfo[MAX_BUF_MEDIUM];  char        szPercentString[MAX_BUF_MEDIUM];  char        szPercentageCompleted[MAX_BUF_MEDIUM];  static long lModLastValue = 0;  double        dRate;  static double dRateCounter;  static DWORD  dwTickStart = 0;  DWORD         dwTickNow;  DWORD         dwTickDif;  DWORD         dwKBytesSoFar;  DWORD         dwRoundedRate;  char          szTimeLeft[MAX_BUF_TINY];  /* If the user just clicked on the Resume button, then the time lapsed   * between dwTickStart and when the Resume button was clicked needs to   * be subtracted taken into account when calculating dwTickDif.  So   * "this" lapsed time needs to be added to dwTickStart. */  if(gtiPaused.bTickDownloadResumed)  {    dwTickStart = AddToTick(dwTickStart, gtiPaused.dwTickDif);    InitTickInfo();  }  /* GetTickCount() returns time in milliseconds.  This is more accurate,   * which will allow us to get at a 2 decimal precision value for the   * download rate. */  dwTickNow = GetTickCount();  if(dwTickStart == 0)    dwTickNow = dwTickStart = GetTickCount();  dwTickDif = GetTickDif(dwTickNow, dwTickStart);  /* Only update the UI every UPDATE_INTERVAL_STATUS interval,   * which is currently set to 1 sec. */  if(!CheckInterval(&lModLastValue, UPDATE_INTERVAL_STATUS))    return;  if(glAbsoluteBytesSoFar == 0)    dRateCounter = 0.0;  else    dRateCounter = dwTickDif / 1000;  if(dRateCounter == 0.0)    dRate = 0.0;  else    dRate = (glAbsoluteBytesSoFar - glBytesResumedFrom) / dRateCounter / 1024;  dwKBytesSoFar = glAbsoluteBytesSoFar / 1024;  /* Use a rate that is rounded to the nearest integer.  If dRate used directly,   * the "Time Left" will jump around quite a bit due to the rate usually    * varying up and down by quite a bit. The rounded rate give a "more linear"   * count down of the "Time Left". */  dwRoundedRate = RoundDouble(dRate);  if(dwRoundedRate > 0)    GetTimeLeft((glTotalKb - dwKBytesSoFar) / dwRoundedRate,                 szTimeLeft,                 sizeof(szTimeLeft));  else    lstrcpy(szTimeLeft, "00:00:00");  if(!gbShowDownloadRetryMsg)  {    GetPrivateProfileString("Strings",                            "Status Download",                            "",                            szStatusStatusLine,                            sizeof(szStatusStatusLine),                            szFileIniConfig);    if(*szStatusStatusLine != '\0')      sprintf(szCurrentStatusInfo,              szStatusStatusLine,              szTimeLeft,              dRate,              dwKBytesSoFar,              glTotalKb);    else      sprintf(szCurrentStatusInfo,              "%s at %.2fKB/sec (%uKB of %uKB downloaded)",              szTimeLeft,              dRate,              dwKBytesSoFar,              glTotalKb);  }  else  {    GetPrivateProfileString("Strings",                            "Status Retry",                            "",                            szStatusStatusLine,                            sizeof(szStatusStatusLine),                            szFileIniConfig);    if(*szStatusStatusLine != '\0')      sprintf(szCurrentStatusInfo,              szStatusStatusLine,              szTimeLeft,              dRate,              dwKBytesSoFar,              glTotalKb);    else      sprintf(szCurrentStatusInfo,              "%s at %.2KB/sec (%uKB of %uKB downloaded)",              szTimeLeft,              dRate,              dwKBytesSoFar,              glTotalKb);  }  GetPrivateProfileString("Strings",                          "Status Percentage Completed",                          "",                          szPercentageCompleted,                          sizeof(szPercentageCompleted),                          szFileIniConfig);  wsprintf(szPercentString, szPercentageCompleted, (int)GetPercentSoFar());  /* Set the download dialog title */  SetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS_STATUS, szCurrentStatusInfo);  SetDlgItemText(dlgInfo.hWndDlg, IDC_PERCENTAGE, szPercentString);}