如鹏网 大学生计算机学习社区

CowNew开源团队

http://www.cownew.com 邮件请联系 about521 at 163.com

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  363 随笔 :: 2 文章 :: 808 评论 :: 0 Trackbacks

procedure TMainForm.CopyFileByFolder(Ahandle: THandle; fromDir,
  toDir: String);
var
  SHFileOpStruct: TSHFileOpStruct;
  pFromDir, pToDir: PAnsiChar;
begin
  GetMem(pFromDir, Length(fromDir)+2);
  try
    GetMem(pToDir, Length(toDir)+2);
    try

      FillChar(pFromDir^, Length(fromDir)+2, 0);
      FillChar(pToDir^, Length(toDir)+2, 0);

      StrCopy(pFromDir, PChar(fromDir));
      StrCopy(pToDir, PChar(toDir));

      with SHFileOpStruct do
      begin
        Wnd    := AHandle;   // Assign the window handle
        wFunc  := FO_COPY;  // Specify a file copy
        pFrom  := pFromDir;
        pTo    := pToDir;
        fFlags := FOF_NOCONFIRMATION or FOF_SILENT;
        fAnyOperationsAborted := True;
        hNameMappings := nil;
        lpszProgressTitle := nil;
        if SHFileOperation(SHFileOpStruct) <> 0 then
          RaiseLastWin32Error;
      end;
    finally
      FreeMem(pToDir, Length(ToDir)+2);
    end;
  finally
    FreeMem(pFromDir, Length(FromDir)+2);
  end;
end;

posted on 2006-12-31 00:18 CowNew开源团队 阅读(1999) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: