码迷,mamicode.com
首页 > 编程语言 > 详细

C++ 回调函数,拷贝文件

时间:2020-03-03 16:22:36      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:sed   ase   nat   signed   ota   msi   names   iostream   bytes   

#include <iostream>
#include <windows.h>
using namespace std;


unsigned long long translate(LARGE_INTEGER num)
{
    unsigned long long reslut = num.HighPart;
    reslut << 32;
    reslut += num.LowPart;
    return reslut;
}

DWORD CALLBACK CopyProgress(
    LARGE_INTEGER TotalFileSize,            // total file size, in bytes
    LARGE_INTEGER TotalBytesTransferred,    // total number of bytes transferred
    LARGE_INTEGER StreamSize,                // total number of bytes for this stream
    LARGE_INTEGER StreamBytesTransferred,    // total number of bytes transferred for this stream
    DWORD dwStreamNumber,                    // the current stream
    DWORD dwCallbackReason,                    // reason for callback
    HANDLE hSourceFile,                        // handle to the source file
    HANDLE hDestinationFile,                // handle to the destination file
    LPVOID lpData                            // passed by CopyFileEx
    )
{
    
    unsigned long long total = translate(TotalFileSize);
    unsigned long long copied = translate(TotalBytesTransferred);
    printf("进度:%I64d / %I64d \n", copied, total);

   
    return PROGRESS_CONTINUE;
}

int main()
{
   
    BOOL ss = CopyFileEx("D:\\BaiduNetdiskDownload\\123.exe", "c:\\111111_copy.txt", &CopyProgress, NULL, NULL, NULL);

    cout << (ss ? "ture" : "flase");

  
    return 0;
}

  

C++ 回调函数,拷贝文件

标签:sed   ase   nat   signed   ota   msi   names   iostream   bytes   

原文地址:https://www.cnblogs.com/shenji/p/12402898.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!