Hello everyone,
 
To whom interested to know my problem, here is my answer.
The problem is I used some third party code from JVCL which has a routine GetCPUSpeed in unit JclSysInfo.pas. Because the customer machine is P4 2.8GHZ machine, the value of Ticks return is zero which cause access violation, as this code is called by initialization section, there is no exception handling code. Report straight back to Windows.
 
I don't understand why Program Compatibility Mode can hide the problem. I have used comment to solve the problem.
 
Regards
Leigh
 
function GetCPUSpeed(var CpuSpeed: TFreqInfo): Boolean;
var
  T0, T1: TULargeInteger;
  CountFreq: TULargeInteger;
  Freq, Freq2, Freq3, Total: Integer;
  TotalCycles, Cycles: Int64;
  Stamp0, Stamp1: Int64;
  TotalTicks, Ticks: Cardinal;
  Tries, Priority: Integer;
  Thread: THandle;
begin
  Stamp0 := 0;
  Stamp1 := 0;
  Freq  := 0;
  Freq2 := 0;
  Freq3 := 0;
  Tries := 0;
  TotalCycles := 0;
  TotalTicks := 0;
  Total := 0;
 
  Thread := GetCurrentThread();
  Result := QueryPerformanceFrequency(Int64(CountFreq));
  if Result then
  begin
    while ((Tries < 3 ) or ((Tries < 20) and ((Abs(3 * Freq - Total) > 3) or
      (Abs(3 * Freq2 - Total) > 3) or (Abs(3 * Freq3 - Total) > 3)))) do
    begin
      Inc(Tries);
      Freq3 := Freq2;
      Freq2 := Freq;
      QueryPerformanceCounter(Int64(T0));
      T1.LowPart := T0.LowPart;
      T1.HighPart := T0.HighPart;
 
      Priority := GetThreadPriority(Thread);
      if Priority <> THREAD_PRIORITY_ERROR_RETURN then
        SetThreadPriority(Thread, THREAD_PRIORITY_TIME_CRITICAL);
      try
        while (T1.LowPart - T0.LowPart) < 50 do
        begin
          QueryPerformanceCounter(Int64(T1));
          Stamp0 := ReadTimeStampCounter;
        end;
        T0.LowPart := T1.LowPart;
        T0.HighPart := T1.HighPart;
 
        while (T1.LowPart - T0.LowPart) < 1000 do
        begin
          QueryPerformanceCounter(Int64(T1));
          Stamp1 := ReadTimeStampCounter;
        end;
      finally
        if Priority <> THREAD_PRIORITY_ERROR_RETURN then
          SetThreadPriority(Thread, Priority);
      end;
 
      Cycles := Stamp1 - Stamp0;
      Ticks := T1.LowPart - T0.LowPart;
      Ticks := Ticks * 100000;
     
      Ticks := Round(Ticks / (CountFreq.LowPart / 10));
      TotalTicks := TotalTicks + Ticks;
      TotalCycles := TotalCycles + Cycles;
 
      // leigh wanstead
      if Ticks = 0 then
      begin
        Freq := Cycles;
      end
      else
      begin
        Freq := Round(Cycles / Ticks);
      end;
 
      // leigh wanstead
 
//      Freq := Round(Cycles / Ticks);
      Total := Freq + Freq2 + Freq3;
    end;
 
    Freq3 := Round((TotalCycles * 10) / TotalTicks);
    Freq2 := Round((TotalCycles * 100) / TotalTicks);
 
    if Freq2 - (Freq3 * 10) >= 6 then
      Inc(Freq3);
 
    CpuSpeed.RawFreq := Round(TotalCycles / TotalTicks);
    CpuSpeed.NormFreq := CpuSpeed.RawFreq;
 
    Freq := CpuSpeed.RawFreq * 10;
    if (Freq3 - Freq) >= 6 then
      Inc(CpuSpeed.NormFreq);
 
    CpuSpeed.ExTicks := TotalTicks;
    CpuSpeed.InCycles := TotalCycles;
 
    CpuSpeed.NormFreq := RoundFrequency(CpuSpeed.NormFreq);
    Result := True;
  end;
end;
 
 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Leigh Wanstead
Sent: Wednesday, March 17, 2004 9:23 AM
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] Using Program Compatibility Mode

Hello everyone,
 
I am using Delphi 7 to develop an win32 application which runs on Win95, Win98, Windows 2000, Windows XP including SP1.
 
The application I developed did not work on a machine from a customer which run on Windows XP SP1 this morning. If the application changed to run under Win98 compatibility mode, it works, without speicifying it or specify anything greater than Win98 compatibility mode, it just simply crash, and Windows display error box.
 
 
My questions is how can I know which part of delphi code cause that problem? How can I detect it? Do I have to install Delphi 7 on this customer machine to know it? Or install remote debugger?
 
TIA
 
Regards
Leigh
 
_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to