首页 | 业界新闻 | 黑客教程 | 安全漏洞 | 安全文章 | 破解技术 | 技术文摘 | 黑客文化 | 本站原创 | 安全贴吧 | 在线留言 | IP查询 | 软件下载 | 繁体中文 |
您现在的位置: 黑色反击 >> 技术资讯 >> 技术文摘 >> 编程频道 >> DELPHI >> 正文
DELPHI公用函数二
时间:2005-2-24 18:16:41 出处:网络 作者:未知 编辑:mervin 点击数:

function TPub.StrReplaceString(var S: string; const Token, NewToken: string; bCaseSensitive: Boolean): Boolean;
var
I : Integer;
sFirstPart: string;
begin
if bCaseSensitive then
I := AnsiPos(Token, S)
else
I := AnsiPos(AnsiUpperCase(Token), AnsiUpperCase(S));

if I <> 0 then
begin
sFirstPart := Copy(S, 1, I - 1) + NewToken;
S := Copy(S, I + Length(Token), Maxint);
end;

Result := I <> 0;
if Result then
begin
StrReplaceString(S, Token, NewToken, bCaseSensitive);
S := sFirstPart + S;
end;
end;

procedure TPub.StrSimple_ReplaceString(var S: string; const Substr: string; index, Count: Integer);
begin
S := Format('%s%s%s',[Copy(S, 1, index - 1), Substr, Copy(S, index + Count, Maxint)]);
end;

function TPub.StrCompositeStrings(SL: TStrings; const Delimiter: string): string;
var
I: Integer;
begin
Result := '';

with SL do
begin
for I := 0 to Count - 2 do
Result := Result + Strings[I] + Delimiter;
if Count > 0 then
Result := Result + Strings[Count - 1];
end;
end;

function TPub.StrSafeLoadStrings(SL: TStrings; const Filename: string): Boolean;
begin
Result := False;
repeat
try
if not FileExists(Filename) then Exit;
SL.LoadFromFile(Filename);
Result := True;
Break;
except
Sleep(500);
end;
until False;
end;

procedure TPub.StrSafeSaveStrings(SL: TStrings; const Filename: string);
begin
ForceDirectories(ExtractFilePath(Filename));
repeat
try
SL.SaveToFile(Filename);
Break;
except
Sleep(500);
end;
until False;
end;
//以下字体
function TPub.FontToString(Font: TFont; bIncludeColor: Boolean): string;
var
sStyle: string;
begin
with Font do
begin
// convert font style to string
sStyle := '';

if (fsBold in Style) then
sStyle := sStyle + csfsBold;

if (fsItalic in Style) then
sStyle := sStyle + csfsItalic;

if (fsUnderline in Style) then
sStyle := sStyle + csfsUnderline;

if (fsStrikeOut in Style) then
sStyle := sStyle + csfsStrikeout;

if ((Length(sStyle) > 0) and ('|' = sStyle[1])) then
sStyle := Copy(sStyle, 2, Length(sStyle) - 1);

Result := Format('"%s", %d, [%s]',[name, Size, sStyle]);
if bIncludeColor then
Result := Result + Format(', [%s]',[ColorToString(Color)]);
end;
end;

procedure TPub.StringToFont(sFont: string; Font: TFont;
bIncludeColor: Boolean);
var
P : Integer;
sStyle: string; // Expected format:
begin // "Arial", 9, [Bold], [clRed]
with Font do //
try
// get font name
P := Pos(',', sFont);
name := Copy(sFont, 2, P - 3);
Delete(sFont, 1, P);

// get font size
P := Pos(',', sFont);
Size := StrToInt(Copy(sFont, 2, P - 2));
Delete(sFont, 1, P);

// get font style
P := Pos(',', sFont);
sStyle := '|' + Copy(sFont, 3, P - 4);
Delete(sFont, 1, P);

// get font color
if bIncludeColor then
Color := StringToColor(Copy(sFont, 3, Length(sFont) - 3));

// convert str font style to
// font style
Style := [];

if (Pos(csfsBold, sStyle) > 0) then
Style := Style + [fsBold];

if (Pos(csfsItalic, sStyle) > 0) then
Style := Style + [fsItalic];

if (Pos(csfsUnderline, sStyle) > 0) then
Style := Style + [fsUnderline];

if (Pos(csfsStrikeout, sStyle) > 0) then
Style := Style + [fsStrikeOut];
except
end;
end;

procedure TPub.ConWriteText(aContr: TControl;sText: string);
var
c:TCanvas;
begin
c:=TControlCanvas.Create;
TControlCanvas(c).Control := aContr;
c.Font.Size := 12;// Brush.Style:=bsClear;
c.Font.Color := clBlue;
//c.Pen.Color:=clBlue;
c.TextOut(1,1,sText);// Rectangle(5,5,15,15);
c.Free;
end;


procedure TPub.FileCopyDirectory(sDir, tDir: string);
var
aWaitForm: TForm;
RetValue: integer;
procedure MyCop

[1] [2] [3] [4] [5] [6] [7] [8] 下一页

精彩推荐
hack菜鸟入门
VB 从零开始编外挂(完
IPC入侵全接触
QQ跨站漏洞巧利用,强
WinXP中CPU占用100%原
黑客新技术 灰鸽子巧妙
实例讲解 黑客入侵论坛
ADSL共享上网方式大总
BMP文件格式分析
十招教你学会破解
热门软件
网 友 评 论
关于我们 - 联系方式 - 招聘信息 - 合作伙伴 - 网站地图 - 广告服务 - 我要投稿 - 设为首页 - 加入收藏
黑色反击 力倡网络安全,崇尚互联共享,欢迎各种媒体转载我们的原创作品 [转载请注明出处]。
EMAIL:hf110.com@gmail.com 备案:苏ICP备05010002号