Delphi ×Ö·û´®²Ù×÷
³£Íü¼Ç£¬ÔÚ´Ë×ö±Ê¼Ç¡£
Õ⼸¸öº¯Êý¶¼°üº¬ÔÚStrUtilsÖУ¬ËùÒÔÐèÒªuses StrUtils;
¼ÙÉè×Ö·û´®ÊÇ Dstr := ’Delphi is the BEST’, ÄÇô
LeftStr(Dstr, 5) := ’Delph’
MidStr(Dstr, 6, 7) := ’i is th’
RightStr(Dstr, 6) := ’e BEST’
~~~~~~~~~~~~~~~~~~~~~~~~~
function RightStr
(Const Str: String; Size: Word): String;
begin
if Size > Length(Str) then Size := Length(Str) ;
RightStr := Copy(Str, Length(Str)-Size+1, Size)
end;
function MidStr
(Const Str: String; from, Size: Word): String;
begin
MidStr := Copy(Str, from, Size)
end;
function LeftStr
(Const Str: String; Size: Word): String;
begin
LeftStr := Copy(Str, 1, Size)
end;
Õ⼸¸öº¯Êý¾³£½áºÏPos, Length, CopyʹÓÃ
²ð·Ö×Ö·û´®µÄº¯Êý [2005-12-13]
delphiÖÐûÓÐÌṩ´ËÀຯÊý£¬´Ó´ó¸»ÎÌÕÒÁËÒ»¸ö
function split(src,dec : string):TStringList;
var
i : integer;
str : string;
begin
result := TStringList.Create;
repeat
i := pos(dec,src);
str := copy(src,1,i-1);
if (str='') and (i>0) then
begin
delete(src,1,length(dec));
continue;
end;
if i
Ïà¹ØÎĵµ£º
procedure mc_SplitStr(sourStr:String;splitChar:String;desLst:TStringList);
var
tmpStr:String;
sValue:String;
iStart,iPos:Integer;
begin
try
desLst.Clear; //ºÜÖØÒª£¬·ñÔò£¬»áÒ» ......
ÕâÊÇÒ»¸öʵÀý£º
procedure TMainForm.Button1Click(Sender: TObject);
var
arr:array of array of string;
begin
setlength(arr,2,3);
arr[1,2]:='this is a test';
setlength(arr,0,0);
setlength(arr,4,5);
showmessage(arr[1,2]);
end;
ÉùÃ÷Ò»¸ö¶þάÊý×éµÄ·½·¨ÊÇÓ ......
(Ò») ʹÓö¯Ì¬´´½¨µÄ·½·¨
Ê×ÏÈ´´½¨ Excel ¶ÔÏó£¬Ê¹ÓÃComObj:
var ExcelApp: Variant;
ExcelApp := CreateOleObject( 'Excel.Application' );
1) ......
¿ª·¢Õß¶¼Ï£Íû×Ô¼ºµÄ³ÌÐòÓÐÒ»¸öÓѺõĽçÃæ£¬´Ëʱ£¬Ò»¸öÉú¶¯»îÆÃ¡¢ÓбíÏÖÁ¦µÄ¹â±ê¾Í±Ø²»¿ÉÉÙÁË¡£Windows ȱʡÌṩ22ÖÖ±ê×¼¹â±ê¹©ÔÚ³ÌÐòÖе÷Ó㬵«¶ÔÒ»¸öÇóÐÂÇó±äµÄ³ÌÐòÔ±À´Ëµ£¬±ê×¼¹â±ê¾Í²»ÄÜÂú×ãÒªÇóÁË£¬ÐèҪʹÓÃ×Ô¼ºµÄ¹â±ê£¬ÄÇô£¬ÔÚ³ÌÐòÖÐÔõÑùʹÓÃ×Ô¼ºµÄ¹â±êÄØ£¿ ¡¡¡¡¡ñ¹â±ê×ÊÔ´µÄ»ñµÃ ¡¡¡¡ÒªÊ¹ÓÃ×Ô¶¨Òå¹â±ê£¬±ØÐëÏȵõ½Õâ ......
VCÉùÃ÷
HANDLE CreateMutex(
¡¡¡¡LPSECURITY_ATTRIBUTES lpMutexAttributes, // SD
¡¡¡¡BOOL bInitialOwner, // initial owner
¡¡¡¡LPCTSTR lpName // object name
¡¡¡¡);
delphiÉùÃ÷£º
function CreateMutex(lpMutexAttributes: PSecurityAttributes; bInitialOwner: BOOL; lpName: PChar): THandle; stdcall;
´´½ ......