Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

DelphiÖÐʵÏÖ³ÌÐòµÄÑÓʱµÄ·½·¨

ÔÚDelphiÖУ¬Í¨³£¿ÉÒÔÓÃÒÔÏÂÈýÖÖ·½·¨À´ÊµÏÖ³ÌÐòµÄÑÓʱ£¬¼´TTtimer¿Ø¼þ£¬Sleepº¯Êý£¬GetTickCountº¯Êý¡£µ«ÊÇÆ侫¶ÈÊǸ÷²»ÏàͬµÄ¡£
Ò»¡¢ÈýÖÖ·½·¨µÄ¼òµ¥½éÉÜ
1£©TTtimer¿Ø¼þ
¡¡¡¡TTtimer¿Ø¼þµÄʵÖÊÊǵ÷ÓÃWindows API¶¨Ê±º¯ÊýSetTimerºÍKillTimerÀ´ÊµÏֵģ¬²¢¼ò»¯Á˶ÔWM_TIMER ÏûÏ¢µÄ´¦Àí¹ý³Ì¡£Í¨¹ýÉèÖÃOnTimerÊÂ
¼þºÍIntervalÊôÐÔ£¬ÎÒÃÇ¿ÉÒԺܷ½±ãµÄ²úÉúһЩ¼òµ¥µÄ¶¨Ê±Ê¼þ¡£
2£©Sleepº¯Êý
¡¡¡¡Sleepº¯ÊýÓÃÀ´Ê¹³ÌÐòµÄÖ´ÐÐÑÓʱ¸ø¶¨µÄʱ¼äÖµ¡£SleepµÄµ÷ÓÃÐÎʽΪSleep(milliseconds)£¬ÔÝÍ£µ±Ç°µÄ½ø³ÌmillisecondsºÁÃë¡£SleepµÄʵÏÖ
·½·¨ÆäʵҲÊǵ÷ÓÃWindows APIµÄSleepº¯Êý¡£ÀýÈ磺
sleep(1000);        //ÑÓ³Ù1000ºÁÃë
Sleep»áÒýÆð³ÌÐòÍ£ÖÍ£¬Èç¹ûÄãÑÓ³ÙµÄʱ¼ä½Ï³¤µÄ»°£¬ÄãµÄ³ÌÐò½«²»Äܹ»ÏìÓ¦ÑÓʱÆÚ¼äµÄ·¢ÉúµÄÆäËûÏûÏ¢£¬ËùÒÔ³ÌÐò¿´ÆðÀ´ºÃÏñÔÝʱËÀ»ú¡£
3£©GetTickCountº¯Êý
¡¡¡¡ÔÚÖ÷³ÌÐòÖÐÑÓʱ£¬ÎªÁË´ïµ½ÑÓʱºÍÏìÓ¦ÏûÏ¢ÕâÁ½¸öÄ¿µÄ£¬GetTickCount()¹¹³ÉµÄÑ­»·¾ÍÊÇÒ»ÖÖ¹ãΪÁ÷´«µÄ·½·¨¡£ÀýÈ磺
procedure Delay(MSecs: Longint);
//ÑÓʱº¯Êý£¬MSecsµ¥Î»ÎªºÁÃë(ǧ·ÖÖ®1Ãë)
var
FirstTickCount, Now: Longint;
begin
FirstTickCount := GetTickCount();
repeat
    Application.ProcessMessages;
    Now := GetTickCount();
until (Now - FirstTickCount >= MSecs) or (Now < FirstTickCount);
end;
¶þ¡¢¸ß¾«¶ÈµÄ΢ÃÐÔÄܼÆÊýÆ÷£¨high-resolution performance counter£©½éÉÜ
¡¡¡¡ÎªÁ˱ȽÏÒÔÉÏ·½·¨µÄ¾«¶È£¬Ê×ÏÈÐèÒªÕÒµ½Ò»¸ö²Î¿¼µÄ¶¨Ê±Æ÷¡£ÔÚÕâÀÎÒÌṩÁËÁ½¸ö²Î¿¼µÄ¶¨Ê±Æ÷¡£Ò»ÊÇÓõ¥Æ¬»úÿ¸ô1.024ms²úÉúÒ»¸öʵʱ
ÖжÏRTI£¬×÷Ϊ¼ÆÊýÆ÷£»¶þÊÇÑ¡ÓÃÁËÒ»¸ö¸ß¾«¶ÈµÄ΢ÃÐÔÄܼÆÊýÆ÷£¨²Î¼û£º
http://msdn.microsoft.com/msdnmag/issues/04/03/HighResolutionTimer/default.aspx £¬»òÕß
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=200249
£©
1£©¼ÆÊýÆ÷µÄDelphiÔ´´úÂë
{
A high-precision counter/timer. Retrieves time differences
                               downto microsec.
Quick Reference:
           


Ïà¹ØÎĵµ£º

Override Delphi Form's Restore Operation

{ Private declarations }
procedure WMSysCommand (var Msg: TWMSysCommand) ; message WM_SYSCOMMAND;
procedure TForm1.WMSysCommand(var Msg: TWMSysCommand);
begin
if Msg.CmdType = SC_RESTORE then
begin
ShowMessage('SC_RESTORE');
if self.WindowState = wsMaximized then
begin
......

ÔÚdelphi 7ÖÐʵÏÖ»ñÈ¡ºº×ÖÆ´ÒôÊ××Öĸ

     ¹«Ë¾µÄ²ÍÒûϵͳ³öÆ·µÄÖú¼ÇÂ룬»¹Ã»ÊµÏÖ×Ô¶¯´Ó³öÆ·Ãû³Æ»ñÈ¡ºº×ÖÆ´ÒôÊ××Öĸ¡£
   ËùÒÔÔÚÍøÉÏÕÒÁËÈýÖÖ½â¾ö·½·¨£¬
    Ò»ÖÖÊÇkaguo µÄʹÓó£Óúº×ÖÆ´Òô²éÕÒ·½·¨£¬ÕâÖÖ´úÂëÊ®·Ö¼òµ¥£¬ÊµÏÖ·½±ã£¬µ«ÊÇÕâÖÖ´úÂë½ö½öÊÇÒ»¼¶×ֿ⣬ֻ֧³ÖÈýǧÁ㼸¸ö×ֵġ£
//»ñÈ¡ÖÐÎÄ×Ö´®µÄÉùĸµ ......

delphi ÅжÏÍøÂçÊÇ·ñÁ¬Í¨µÄ·½·¨

uses WinInet;
procedure TForm1.Button1Click(Sender: TObject);
begin
  if InternetGetConnectedState(nil, 0) then
    ShowMessage('ÒÑÁ¬½Ó')
  else
    ShowMessage('ÒѶϿª');
end; ......

delphi ½«ºº×Ö·­Òë³ÉÆ´ÒôËõдµÄº¯Êý½éÉÜ

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
 &n ......

delphi È¡CPUÐòÁкŵķ½·¨


interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, ExtCtrls, StdCtrls, Buttons;
type
TDemoForm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
GetButton: TBitBtn;
CloseButton: TBitBtn;
Bevel1: TBevel;
Label5: TLabel; ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ