在DEPHI中根据已知路径打开目录应该怎么写?
解决方案 »
- DateTimePicker的时间的设置问题,为什么我改变了日期,可是读出来时,还是不变!
- delphi 替换页眉的问题
- 有关Delphi皮肤控件使用的问题
- 想统计memo组件里面的某个单词的数量,请高手赐教,谢谢。
- 如何判断一个文件夹是否存在??
- 知道控件的Handle值,怎么获知此控件的类型,并根据相应的控件类设置相应的属性值
- 如何用TQuery和TTable控件表中取值????为什么query1.Fields.Fields[0].Value报错???
- adoquery添加的字段的问题?100分求助!
- 又难死我了!唉~~~~~~
- delphi自己的向下兼容性太差拉! 毛病多多...
- 我要写一个云台控制的程序,不知道谁能给我一些帮助(列子 源代码 步骤之类的)?
- 如果使RICHEDIT的某一行右中或靠左?
const
SELDIRHELP = 1000;
var
dir: String;
begin
dir := 'C:';
if SelectDirectory(dir, [sdAllowCreate, sdPerformCreate, sdPrompt],SELDIRHELP) then
Button1.Caption := dir;
end;
var
Form1: TForm1;
FromDir,ToDir: pchar;
implementation{$R *.dfm}
procedure FileCopy(From, Dest: string);
var T: TSHFileOpStruct;begin
GetMem(FromDir,Length(Fromdir)+2);
try
GetMem(ToDir,Length(Dest)+2);
try
FillChar(FromDir^,Length(From)+2,0);
FillChar(ToDir^,Length(Dest)+2,0); StrCopy(FromDir,PChar(From));
StrCopy(ToDir,PChar(Dest));
with T do
begin
Wnd :=0;
wFunc :=FO_COPY;
pFrom :=FromDir;
pTo :=ToDir;
fflags:=FOF_FILESONLY;
//fFlags :=FOF_RENAMEONCOLLISION ;
//FOF_NOCONFIRMATION; //or FOF_RENAMEONCOLLISION or (FOF_FILESONLY);
fAnyOperationsAborted:=False;
hNameMappings:=nil;
lpszProgressTitle:=nil;
if SHFileOperation(T)<>0 then
raise Exception.Create('拷貝文件失敗!');
end;
finally
FreeMem(ToDir,Length(Dest)+2);
end;
finally
FreeMem(FromDir,Length(From)+2);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
const
SELDIRHELP = 2000;
var
dir: String;
begin
dir := 'q:';
if SelectDirectory(dir, [sdAllowCreate, sdPerformCreate, sdPrompt],SELDIRHELP) then
fromdir:=pchar(dir+'\'+'*.*');
ToDir:='c:\test\';
FileCopy(pchar(fromdir),pchar(todir));
end;end.
uses shellapi;//shellexecute函数在此单元shellexecute(handle,'explorer','C:\windows',nil,nil,...);// 不好意思,参数个数忘了,后面的都设为nil。
procedure TForm1.Button1Click(Sender: TObject);
begin
winexec('c:\winnt\notepad.exe',sw_normal);
end;
樓上的也可以!