COPYFILE同时显示进度条问题

yang8210 2004-07-28 06:45:18
COPYFILE同时,显示进度条
有原代码最好.明天下午5:30结贴.(有完整的原代码+100分)
...全文
674 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
yang8210 2004-07-30
  • 打赏
  • 举报
回复
结了算了,谢谢个各位的参与.
lianglp 2004-07-30
  • 打赏
  • 举报
回复
63633226
lianglp 2004-07-30
  • 打赏
  • 举报
回复
我的QQ,发给你代码!
DoubleJiang 2004-07-29
  • 打赏
  • 举报
回复
SHFileOperation 这个就是windows copy file的dialog
lixiaosan 2004-07-29
  • 打赏
  • 举报
回复
char buf[256];
char buf1[256];
SHFILEOPSTRUCT fo;
memset(buf, 0, sizeof(buf));
memset(buf1, 0, sizeof(buf1));
memset(&fo, 0, sizeof(fo));
strcpy(buf, "f:\\source");
strcpy(buf1, "f:\\target");
fo.wFunc = FO_MOVE;//复制是FO_COPY,删除是FO_DELETE;
fo.pFrom = buf;
fo.pTo = buf1;
fo.fFlags = FOF_SIMPLEPROGRESS;
SHFileOperation(&fo);
yang8210 2004-07-29
  • 打赏
  • 举报
回复
我是菜鸟,我很急,请高手SHOW ME 原代码!!!
yang8210 2004-07-29
  • 打赏
  • 举报
回复
TO : xenix(好学不好用,好用不好学)
我去试试先
yang8210 2004-07-29
  • 打赏
  • 举报
回复
zhucde(【風間苍月】)
你能不能帮帮我,整理一下行吗,谢谢先
yang8210 2004-07-29
  • 打赏
  • 举报
回复
TO: lixiaosan(小三)
我要的不是 SHFileOperation 这个就是windows copy file的dialog
不过,也谢谢先

hushuoqiu 2004-07-29
  • 打赏
  • 举报
回复
那么中途想退出的话是不是必须用多线程?
kvw3000 2004-07-29
  • 打赏
  • 举报
回复
现在要实现拷贝文件的功能,时间较长.不想自己做个进度条,问能不能调用windows中拷贝文件的那个进度条?
---------------------------------------------------------------

Requirements
Version 5.00 and later of Shell32.dll

Windows NT/2000: Requires Windows 2000.
Windows 95/98/Me: Requires Windows Me.

IProgressDialog
The IProgressDialog interface is exported by the progress dialog box object (CLSID_ProgressDialog). This object is a generic way to show a user how an operation is progressing. It is typically used when deleting, uploading, copying, moving, or downloading large numbers of files.

The progress dialog box object creates a modeless dialog box and allows the client to set its title, animation, text lines, and progress bar. The object then handles updating on a background thread and allows the user to cancel the operation. Optionally, it estimates the time remaining until the operation is complete and displays the information as a line of text.

BUG: PROGDLG_NOMINIMIZE Flag in IProgressDialog::StartProgressDialog() Has No Effect

Q260222


--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Win32 Software Development Kit (SDK), on platform(s):
the operating system: Microsoft Windows 2000
xenix 2004-07-29
  • 打赏
  • 举报
回复
就是从源文件读入一块(建议1024KB),然后写入目标文件,并同时显示进度,如此重复直到读完
xenix 2004-07-29
  • 打赏
  • 举报
回复

INT64 CopyCoder::Copy2(IO::IStream *inStream, const INT64* inSize, IO::IStream *outStream)
{
INT64 retVal = 0;
INT64 readSize = 0;

const INT64 bufferSize =m_buffer.GetSize();

BYTE *buffer = m_buffer;

const bool limitSize = inSize != NULL;

INT64 bytesLeft = limitSize ? *inSize : bufferSize;
while(true)
{
if(limitSize)
{
if(bytesLeft <= 0)break;
}
else
{
bytesLeft = bufferSize;
}

size_t readBytes = (size_t)Min(bytesLeft, bufferSize);
readBytes = inStream->Read(buffer, readBytes);
if(readBytes == 0)break;
readSize += readBytes;
const size_t writeBytes = outStream->Write(buffer, readBytes);


retVal += writeBytes;
bytesLeft -= readBytes;

if(m_progress != NULL)
{
m_progress->SetProgress(readSize, retVal);
}

}

return retVal;
}

来自于我的程序的一部分,自己修改一下
holyeagle 2004-07-29
  • 打赏
  • 举报
回复
对多文件操作可以参考msdn,有详细说明。
zhucde 2004-07-29
  • 打赏
  • 举报
回复
代码我这有,但整理出来花时间.

你可以先遍历一下文件夹,统计多少个数,
然后根据个数来控制进度条.
这个比根据大小来控制相对简单一些
Blue_Light 2004-07-28
  • 打赏
  • 举报
回复
WINSHELLAPI int WINAPI SHFileOperation(
LPSHFILEOPSTRUCT lpFileOp
);

最标准的,Windows就是用它
wwww2 2004-07-28
  • 打赏
  • 举报
回复
对啊,用CopyFileEx()函数
chenxingang 2004-07-28
  • 打赏
  • 举报
回复
一时找不到代码我只能给你说个大概你可以用多线程的方式,一个界面线程显示进度进度另一个线程拷贝文件,通过消息进行通信.单线程也可以实现不过当你运行时有别的窗口挡住你的进度条时再次显示会看不到取消按钮且不能移动.
lianglp 2004-07-28
  • 打赏
  • 举报
回复
请用CopyFileEx()API函数就可以实现 。

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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