本文整理自网络,侵删。
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 2009 新增单元 character[1]: toupper、tolower - 字符与字符串的大小写转换
Delphi使用spcomm串口通信 串口号大于10出错的解决办法
Delphi cef4Delphi chromium1 设置user-agent
Delphi 使用shellexecuteex运行应用程序并等待完成
Delphi xe7里面 sharedactivitycontext怎么提示错误?
更多相关阅读请进入《Delphi》频道 >>