C++ (Qt) LPCSTR q=QString("C:\\am74364.dll").toLocal8Bit().data(); LPCSTR a=QString("C:\\a\\am74364.dll").toLocal8Bit().data(); BOOL ok=true; CopyFileA(q,a,ok);
C++ (Qt) LPCSTR q=QString("C:\\pagefile.sys").toLocal8Bit().data(); LPCSTR a=QString("C:\\a\\pagefile.sys").toLocal8Bit().data(); BOOL ok=true; CopyFileA(q,a,ok);
C++ (Qt)QFile::copy("/path/file", "/path/copy-of-file");
C++ (Qt)BOOL CopyFileEx( LPCTSTR lpExistingFileName, // имя существующего файла LPCTSTR lpNewFileName, // имя нового файла LPPROGRESS_ROUTINE lpProgressRoutine, // функция обратного вызова LPVOID lpData, // параметры обратного вызова LPBOOL pbCancel, // отмененный статус DWORD dwCopyFlags // опции копирования);
C++ (Qt)DWORD CALLBACK CopyProgressRoutine( LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER StreamSize, LARGE_INTEGER StreamBytesTransferred, DWORD dwStreamNumber, DWORD dwCallbackReason, HANDLE hSourceFile, HANDLE hDestinationFile, LPVOID lpData);
C++ (Qt)DWORD CALLBACK MainWindow::CopyProgressRoutine(LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER StreamSize, LARGE_INTEGER StreamBytesTransferred, DWORD dwStreamNumber, DWORD dwCallbackReason, HANDLE hSourceFile, HANDLE hDestinationFile, LPVOID lpData) { return PROGRESS_CONTINUE;}
C++ (Qt)CopyFileExA(q,a,&CopyProgressRoutine,NULL,FALSE,COPY_FILE_FAIL_IF_EXISTS);
C++ (Qt)DWORD CALLBACK CopyProgressRoutine( LARGE_INTEGER TotalFileSize, // размер файла LARGE_INTEGER TotalBytesTransferred, // переносимые байты LARGE_INTEGER StreamSize, // байты в потоке LARGE_INTEGER StreamBytesTransferred, // переносимые потоком байты DWORD dwStreamNumber, // текущий поток DWORD dwCallbackReason, // причина возврата HANDLE hSourceFile, // дескриптор источ. файла HANDLE hDestinationFile, // дескриптор целевого файла LPVOID lpData // из CopyFileEx
C++ (Qt)LPCSTR q=QString("C:\\am74364.dll").toLocal8Bit().data(); LPCSTR a=QString("C:\\a\\am74364.dll").toLocal8Bit().data(); BOOL ok=true; LPPROGRESS_ROUTINE progre; CopyFileA(q,a,ok);
C++ (Qt)#include "mainwindow.h"#include "ui_mainwindow.h" //#include <winbase.h> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); LPCSTR q=QString("C:\\am74364.dll").toLocal8Bit().data(); LPCSTR a=QString("C:\\a\\am74364.dll").toLocal8Bit().data(); LPPROGRESS_ROUTINE d; BOOL ok=true; LPPROGRESS_ROUTINE progre; CopyFileExA(q,a,CopyProgressRoutine,NULL, 0, COPY_FILE_FAIL_IF_EXISTS); } MainWindow::~MainWindow(){ delete ui;} DWORD CALLBACK MainWindow::CopyProgressRoutine(LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER StreamSize, LARGE_INTEGER StreamBytesTransferred, DWORD dwStreamNumber, DWORD dwCallbackReason, HANDLE hSourceFile, HANDLE hDestinationFile, LPVOID lpData){ ui->progressBar->setValue(TotalBytesTransferred.QuadPart/TotalFileSize.QuadPart); return PROGRESS_CONTINUE;}
C++ (Qt) CopyFileExA(q,a,CopyProgressRoutine,NULL, 0, COPY_FILE_FAIL_IF_EXISTS);
D:\423423\copy\mainwindow.cpp:23: ошибка: cannot convert 'MainWindow::CopyProgressRoutine' from type 'DWORD (MainWindow::)(LARGE_INTEGER, LARGE_INTEGER, LARGE_INTEGER, LARGE_INTEGER, DWORD, DWORD, HANDLE, HANDLE, LPVOID) {aka long unsigned int (MainWindow::)(_LARGE_INTEGER, _LARGE_INTEGER, _LARGE_INTEGER, _LARGE_INTEGER, long unsigned int, long unsigned int, void*, void*, void*)}' to type 'LPPROGRESS_ROUTINE {aka long unsigned int (__attribute__((__stdcall__)) *)(_LARGE_INTEGER, _LARGE_INTEGER, _LARGE_INTEGER, _LARGE_INTEGER, long unsigned int, long unsigned int, void*, void*, void*)}' CopyFileExA(q,a,CopyProgressRoutine,NULL, 0, COPY_FILE_FAIL_IF_EXISTS);
C++ (Qt)Test=&CopyProgressRoutine;
C++ (Qt)#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <windows.h>#include <QMainWindow> namespace Ui {class MainWindow;} class MainWindow : public QMainWindow{ Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); DWORD CALLBACK CopyProgressRoutine( LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER StreamSize, LARGE_INTEGER StreamBytesTransferred, DWORD dwStreamNumber, DWORD dwCallbackReason, HANDLE hSourceFile, HANDLE hDestinationFile, LPVOID lpData ); void soobch(); LPPROGRESS_ROUTINE progre; private: Ui::MainWindow *ui;}; #endif // MAINWINDOW_H
C++ (Qt)#include "mainwindow.h"#include "ui_mainwindow.h"#include <QMessageBox> //#include <winbase.h> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); DWORD CALLBACK(*Test)(LARGE_INTEGER,LARGE_INTEGER,LARGE_INTEGER,LARGE_INTEGER,DWORD,DWORD,HANDLE,HANDLE,LPVOID); Test=&CopyProgressRoutine; LPCSTR q=QString("C:\\am74364.dll").toLocal8Bit().data(); LPCSTR a=QString("C:\\a\\am74364.dll").toLocal8Bit().data(); LPVOID data; CopyFileExA(q,a,Test,0,FALSE,COPY_FILE_FAIL_IF_EXISTS); } MainWindow::~MainWindow(){ delete ui;} DWORD CALLBACK MainWindow::CopyProgressRoutine(LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER StreamSize, LARGE_INTEGER StreamBytesTransferred, DWORD dwStreamNumber, DWORD dwCallbackReason, HANDLE hSourceFile, HANDLE hDestinationFile, LPVOID lpData) { ui->progressBar->setValue(TotalBytesTransferred.QuadPart/TotalFileSize.QuadPart); return PROGRESS_CONTINUE;} void MainWindow::soobch(){ QMessageBox msg; msg.setText("11111"); msg.exec();}
C++ (Qt)void MainWindow::on_pushButton_clicked(){ LPCSTR q=QString("D:\\0C").toLocal8Bit().data(); LPCSTR a=QString("D:\\qw\\0C").toLocal8Bit().data();LPVOID lpData; CopyFileExA(q,a,(LPPROGRESS_ROUTINE)&MyCopyProgressRoutine,NULL,FALSE,COPY_FILE_FAIL_IF_EXISTS); DWORD p=GetLastError(); cout<<p<<endl;}
C++ (Qt)DWORD p=GetLastError(); cout<<p<<endl;