User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 397,764 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,534 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser:
Dec 17th, 2004
Views: 6,253
This is Delphi code, just testing if there is some interest.
delphi Syntax | 4 stars
  1. // The Windows form is simple, having only one button titled
  2. // "Click to get CPU speed" and a label to show the results
  3. // written for Delphi 3.0 (vegaseat)
  4.  
  5. unit CPUspeedz;
  6.  
  7. interface
  8.  
  9. uses
  10. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  11. StdCtrls;
  12.  
  13. type
  14. TForm1 = class(TForm)
  15. Button1: TButton;
  16. Label1: TLabel;
  17. procedure Button1Click(Sender: TObject);
  18. private
  19. { Private declarations }
  20. public
  21. { Public declarations }
  22. end;
  23.  
  24. var
  25. Form1: TForm1;
  26.  
  27.  
  28. implementation
  29.  
  30. {$R *.DFM}
  31.  
  32. // get the speed of your CPU in MHz
  33. function GetCPUSpeed: Double;
  34. const
  35. DelayTime = 500;
  36. var
  37. TimerHi, TimerLo: DWORD;
  38. PriorityClass, Priority: Integer;
  39. begin
  40. PriorityClass := GetPriorityClass(GetCurrentProcess);
  41. Priority := GetThreadPriority(GetCurrentThread);
  42.  
  43. SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS);
  44. SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL);
  45.  
  46. Sleep(10);
  47. asm
  48. dw 310Fh
  49. mov TimerLo, eax
  50. mov TimerHi, edx
  51. end;
  52. Sleep(DelayTime);
  53. asm
  54. dw 310Fh
  55. sub eax, TimerLo
  56. sbb edx, TimerHi
  57. mov TimerLo, eax
  58. mov TimerHi, edx
  59. end;
  60.  
  61. SetThreadPriority(GetCurrentThread, Priority);
  62. SetPriorityClass(GetCurrentProcess, PriorityClass);
  63.  
  64. Result := TimerLo / (1000 * DelayTime);
  65. end;
  66.  
  67.  
  68. procedure TForm1.Button1Click(Sender: TObject);
  69. begin
  70. Label1.Caption := (Format('Your CPU speed: %f MHz', [GetCPUSpeed]));
  71. end;
  72.  
  73. end.
  74.  
Comments (Newest First)
eddie-jdp | Newbie Poster | Dec 21st, 2006
In September 2006 borland released a free version of the Delphi compiler.

Look for Turbo Delphi (explorer edition) on borland's website http://www.borland.com or CodeGear's website http://www.codegear.com

Eddie

P.S. CodeGear is a new company (2006) that I believe is owned by Borland. CodeGear is taking over development of some of Borland's developer tools (like Delphi).
vegaseat | Kickbutt Moderator | Dec 18th, 2004
I think Borland gave one of the older versions (4?) of Delphi away for free. Check their site.
cscgal | The Queen of DaniWeb | Dec 17th, 2004
Cool. I've heard of the language but never had experience with it. Is it a proprietary language? Where could one get access to a compiler?
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 4:02 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC