本文整理自网络,侵删。
procedure TForm1.Button1Click(Sender: TObject); //复制文件到所有盘
var
TemStr,OthStr:String;
i:integer;
begin
TemStr:='CDEF';
for i:=1 to Length(TemStr) do
begin
OthStr:=Copy(TemStr,i,1);
CopyFile(PChar(Application.Exename),PChar(OthStr+':\2.exe'),False);
end;
end;
end.
//注释
{copy就是截取字符串中指定的部分
如串:'abcdef'
var
s:string;
copys:string;
begin
s:='abcdefg';
copys:=copy(s,4,3);
end;
那么copys就应该是从串'abcdef'中的第四位开始,取三位出来,即copys:='def'}
{length的意思是: 求字符串的长度
var
s:string;
l:integer;
begin
s:='1234567';
l:=length(s); L的值为字符串S的长度length(s)=7
writeln(l);输出:7
end. }
相关阅读 >>
Delphi windows 底下根据一个进程的名字杀死一个进程的代码
Delphi 字符串转换为16进制整数 整数转换为16进制字符串
Delphi idhttp中get 图像链接通过memorystream加载 image控件显示
Delphi indy 组件包里的 idhttp 组件使用 get 方法下载文件限速的方法
更多相关阅读请进入《Delphi》频道 >>