文件复制和线程问题?

santwy 2002-06-26 02:19:17
在复制文件过程,不使用线程和使用线程,提示窗体不能动了!
原码大概:
void __fastcall copy_file(String filepath_old, String filepath_new)
{
int file_1 , file_2 ;
long file_size = 0 ;
char *buff ;
file_1 = FileOpen(filepath_old , xx );
file_size = FileSeek(file_1, 0, 2);
FileSeek(file_1, 0, 0);
buff = new char[file_size + 1]
FileRead(file_1, buff, file_size);
FileClose(file_1);
file_2 = FileCreate(filepath_new);
FileWrite(file_2, buff, file_size);
FileClose(file_2);
}

//线程里

Exctue
{
copy_file(filepath_old, filepath_new) ;
}

怎样从主窗体传filepath_old \ filepath_new 参数到线程。

我整个想法是像window的复制一样
...全文
24 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
sensation 2002-06-26
  • 打赏
  • 举报
回复
在线程的重写一个构造函数吧,把这两个东西当参数传进去,然后
inherited Create(CreateSuspended);
lj_csdn 2002-06-26
  • 打赏
  • 举报
回复
"怎样从主窗体传filepath_old \ filepath_new 参数到线程。"

delphi会生成如下代码:test(bool CreateSuspended)
: TThread(CreateSuspended)
{
}

->

:test(bool CreateSuspended,String from,String to)
: TThread(CreateSuspended)
{ filepath_old:=from;
filepath_new:=to;
}


knock 2002-06-26
  • 打赏
  • 举报
回复
想知道
luoweicaisd 2002-06-26
  • 打赏
  • 举报
回复
加上这句试一下
application.ProcessMessages

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧