DelphiµÄ·½·¨ÀàÐÍÓУº
1.¾²Ì¬·½·¨ (Static) ĬÈÏÀàÐÍ£¬¿ÉÒÔÊ¡ÂԹؼü×Ö
2.ÐéÄâ·½·¨ (Virtual)
3.¶¯Ì¬·½·¨ (Dynamic)
4.ÏûÏ¢·½·¨ (Message)
5.³éÏó·¨·½ (Abstract)
=======================================================
1£©¾²Ì¬·½·¨[static]
¾²Ì¬·½·¨ÀàËÆÓÚͨ³£µÄ¹ý³ÌºÍº¯Êý£¬±àÒëÆ÷ÔÚ±àÒëʱ¾ÍÒÑÖ¸¶¨ÁËÊä³ö¸Ã·½·¨
µÄ¶ÔÏóʵÀý¡£¾²Ì¬·½·¨µÄÖ÷ÒªÓŵãÊǵ÷ÓÃËٶȿ졣
eg£º
type
TAnimal = class(TObject)
procedure Sound;
procedure Sleep;
... ...
end;
... ...
TDog = class(TAnimal)
procedure Sound;
function Sleep:Integer;
... ...
end;
¾²Ì¬·½·¨²»Äܱ»ÖØÔØ£¬ÉÏÀýÖУ¬ÅÉÉúÀàµÄ¾²Ì¬·½·¨Ö»ÊÇÌæ»»ÁË»ùÀàµÄ¾²Ì¬·½
·¨¡£¼´Ê¹Sleep·½·¨ÔÚTAnimalÖбíÏÖΪ¹ý³Ì¶øÔÚTDogÀàÖбíÏÖΪº¯Êý¡£
=======================================================
2£©ÐéÄâ·½·¨[virtual]
ÐéÄâ·½·¨±È¾²Ì ......
Delphi ÖÐÈçºÎ°²×°×é¼þ?
delphiÖÐÈçºÎ°²×°×é¼þÓÐÎåÖÖÇé¿ö£º
1¡¢Ö»ÓÐÒ»¸öDCUÎļþµÄ×é¼þ¡£DCUÎļþÊDZàÒëºÃµÄµ¥ÔªÎļþ£¬ÕâÑùµÄ×é¼þÊÇ×÷Õß²»Ïë°ÑÔ´Â빫²¼¡£Ò»°ãÀ´Ëµ£¬×÷Õß±ØÐë˵Ã÷´Ë×é¼þÊʺÏDelphiµÄÄÄÖÖ°æ±¾£¬Èç¹û°æ±¾²»¶Ô£¬ÔÚ°²×°Ê±¾Í»á³öÏÖ´íÎó¡£Ò²ÕýÊÇÒòΪûÓÐÔ´Â룬¸øʹÓÃÕß´øÀ´Á˲»±ã£¬ÄǾÍÊÇÒ»µ©Delphi°æ±¾Éý¼¶£¬´Ë×é¼þ¾Í²»ÄÜÔÙʹÓÃÁË£¬µ±È»ÓеÄ×÷Õ߸ø³öÁ˼¸ÖÖ°æ±¾µÄDCUÎļþ£¬Óû§¸ù¾ÝÐèҪѡÔñʹÓá£ÕâÑùµÄ×é¼þµÄ°²×°·½·¨ÊÇ£ºÔÚComponent²Ëµ¥ÖУ¬Ñ¡Ôñinstall component£¬ÔÚ¶Ô»°¿ò “into existing package“Ò³ÖУ¬µ¥»÷“Unit file name”ºóµÄ“Browse”°´Å¤£¬ÔÚ´ò¿ªµÄÎļþ¶Ô»°¿òÖУ¬½«“ÎļþÀàÐÍ”É趨Ϊ*.dcu£¬ÕÒµ½Òª°²×°µÄDCUÎļþ£¬°´OK°´Å¥·µ»Ø“into existing package“Ò³ºóÔÙ°´OK°´Å¥¾Í¿ÉÒÔ°²×°ÁË¡£×¢Ò⣬´ËʱDelphi»áÌáʾdclusr40.dpk½«±»Öؽ¨£¬ÊÇ·ñ¼ÌÐø£¬OK¾Í¿ÉÒÔÁË¡£ÕâÀïÊǽ«×é¼þ°²×°µ½dclusr40.dpk°üÖУ¬´Ë°ü´ÓÎļþÃûÉÏ¿ÉÒÔ¿´³öÊÇÓû§×Ô¶¨Òå×é¼þ°ü£¬ÏÈ°²×°µ½Õâ¸ö°üÖаɣ¬ÏÂÃæÔÙ½²ÓйØ×¢ÒâÊÂÏî¡£°²×°Íê±Ï»áÓÐÒѾ½«×é¼þ×¢²áÍêµÄÌáʾÐÅÏ¢ÒÔ¼°°²×°µ½Äĸö×é¼þÒ³ÖеÄÐÅÏ¢µÈ£¬µ½×é¼þÃæ°åÉÏ¿´¿´£¬Ò»°ã»á³öÏÖÒ»¸öÐ ......
function ListFiles(Dir: String):TStrings;
var
FSearchRec: TSearchRec;
FileList: TStrings;
FindResult: Integer;
begin
if Dir[length(Dir)]<>'\' then Dir:=Dir+'\';
FileList :=TStringList.Create;
FindResult:=FindFirst(Dir+'*.*,faAnyFile+faDirectory,FSearchRec);
while FindResult = 0 do
begin
if ((FSearchRec.Attr and faDirectory) = 0) then //Îļþ
begin
FileList.Add('Îļþ:'+LowerCase(Dir+FSearchRec.Name));
end;
if ((FSearchRec.Attr and faDirectory) <> 0) then
begin
if ((FSearchRec.Name<> '.') and (FSearchRec.Name <> '..')) then //Îļþ¼Ð
begin
ListFiles(dir+FileRec.Name);
end;
end;
FindResult:=FindNext(FSearchRec);
end;
FindClose(FSearchRec);
ListFiles:=FileList;
end;
......
DelphiµÄSocket±à³ÌÒª·Ö¼¸²½£¿
2008-12-20 02:03:24
¡¡±êÇ©£ºDelphi Socket ±à³Ì¡¡¡¡¡¡[ÍÆË͵½¼¼ÊõȦ]
ClientSocket ºÍServerSocket
¼¸¸öÖØÒªµÄÊôÐÔ:
1.clientºÍserver¶¼ÓÐportÊôÐÔ£¬ÐèÒªÒ»Ö²ÅÄÜ»¥ÏàͨÐÅ
2.clientÓÐAddressÊôÐÔ,ʹÓÃʱÌîд¶Ô·½(server)µÄIPµØÖ·
¼¸¸öÖØÒªµÄʼþ:
client: OnReadʼþ£¬µ±clientÊܵ½³å»÷ÏûϢʱÔÚOnReadʼþÖпÉÒÔ»ñµÃserver·¢Ë͹ýÀ´ÏûÏ¢¡£
Server: OnClientReadʼþ£¬ÓëÉÏÊöclientµÄ×÷ÓÃÏàͬ
·¢ËÍÐÅÏ¢£º
clienʹÓÃSocketClient1.Socket.SendBuf(charÀàÐ͵ÄÊý×é,ÐÅÏ¢³¤¶È);
serverʹÓÃSocketServer1.Socket.Connection[0].SendBuf(charÀàÐ͵ÄÊý×é,ÐÅÏ¢³¤¶È);
½ÓÊÕÐÅÏ¢
clienʹÓÃSocketClient1.Soc ......
ÒÔÏÂÊÇÔÚÍøÉÏÊÕ¼¯µÄһЩ¶ÔÎÞÀàÐͲÎÊýµÄ˵Ã÷.¸öÈËÀí½âÎÞÀàÐͱäÁ¿¾ÍÊÇÒ»¸öÖ¸Õë.
ÏóDelphiÖÐfunction Read(var Buffer; Count: Longint): Longint; override;ÏóBufferÕâÑùûÓÐÀàÐ͵IJÎÊý¾¿¾¹Ó¦¸ÃÔõô¸ø²ÎÊý£¿£¿£¿£¿
Õâ˵Ã÷BufferÊÇͨ¹ýµØÖ··½Ê½´«µÝµÄ£¬Ò»°ã˵À´Ö»ÒªÊÇÒ»¶ÎÄÚ´æÇøÓò¾ÍÐС£
var Buffer; const buffer;
ÕâЩûÀàÐÍ˵Ã÷µÄÐβÎ˵Ã÷ÊÇÈ¡µØÖ·µÄÊ×µØÖ·¡£
ÀàÐÍ Ê×µØÖ·
string string[1]
char ×Ô¼º
integer ×Ô¼º
record ×Ô¼º
array arr[0]
pchar pchar()^
pointer pointer()^
& ......
Day ¿ªÍ·µÄº¯Êý
¡ñ
Unit
DateUtils
function DateOf(const Avalue: TDateTime): TDateTime;
ÃèÊö
ʹÓà DateOf º¯ÊýÓÃÀ´°ÑÒ»¸ö TDateTime ÀàÐ͵ıäÁ¿×ª±ä³ÉÒ»¸ö
Ö»´øÓÐÈÕÆÚµÄ TDateTime ÀàÐͱäÁ¿¡£
ÀýÈ磺
showmessage(DateTimetostr(dateof(now())));
ÄãµÃµ½µÄÊÇ 2003/03/19
¶ø showmessage(DateTimetostr((now())));
µÃµ½µÄÊÇ 2003/03/19 10:50:49
¡ñfunction DateTimeToStr(DateTime: TDateTime): string;
ÃèÊö
DateTimeToString º¯Êý½« TDateTime ÀàÐ͵IJÎÊý DateTime ת»»³ÉÒ»¸ö
×Ö·û´®£¬Ê¹Óøø¶¨µÄÈ«¾Ö±äÁ¿ ShortDateFormat µÄ¸ñʽ£¬Ê±¼ä²¿·Ö°´ÕÕ
¸ø¶¨µÄÈ«¾Ö±äÁ¿ LongTimeFormat µÄ¸ñʽ¡£
ÆäÖÐ DateTime ΪÁãµÄ²¿·Ö½«²»»áÏÔʾ³öÀ´¡£
ÀýÈ磺
ShortDateFormat:=’yyyy mm dd’;
showmessage(DateTimetostr((now())));
Ä㽫µÃµ½£º2003 03 19 10:50:49
¡ñprocedure DateTimeToString(var Result: string; const Format: string; DateTime: TDateTime);
ÃèÊö£º
DateTimeToString ·½·¨½«TDateTimeÀàÐ͵IJÎÊýDateTime °´ÕÕÓɲÎÊýFormatÌṩµÄ¸ñʽ
ת»¯³É×Ö·û´®£¬²¢±£´æÔÚResultÖС£
¶ÔÓÚFormatµÄ¸ñʽÀàÐÍ£¬Çë¿´ Date-Time ......