1

In order to protect the binary files (*.exe) that my program used, I reference this post (Adding executables as resources of a Qt application?) to import some of binary files into the QT resource file (if there is a better way to protect the binary file, it would be very helpful to know).

I would like to extract the binary files into temporary directory when program runs. I have tried the QFile::copy with QTemporaryFile::createNativeFile, but some errors showing (I am totally new on C++ and QT, sorry for the stupid questions).

Error Message figure

QT version is 5.4.2

OS: Win7 64bit

Update@0930 0927 UTC: Thanks for the comment from @drescherjm, the error is fixed. But another error showing when I try to use below code to copy the file from resource file to C:.

QFile f(":/test.exe");
f.copy("C:\\test.exe");
qDebug() << "CopyResult" << f.errorString() ;

or

QFile::copy(":/test.exe", "C:\\test.exe");

and the error message is showing, is it a permission issue?

"Cannot create C:\test.exe for output"
Community
  • 1
  • 1
  • 1
    Post error messages verbatim as text in your question please. – πάντα ῥεῖ Sep 29 '16 at 16:00
  • ^ And post the code sample as text. No pictures of text please! – drescherjm Sep 29 '16 at 16:54
  • 2
    The problem is that you seem to be trying to execute code in the class declaration instead of a class member function. – drescherjm Sep 29 '16 at 16:55
  • @drescherjm Yes, you are right, thanks for your comment. – user2187070 Sep 30 '16 at 09:25
  • I believe UAC prevents writing to the root folder of c: on modern windows operating systems. – drescherjm Sep 30 '16 at 13:42
  • ***Update@0930 0927 UTC:*** BTW, You are not supposed to change your topic once a question is asked. You are supposed to ask a single question. StackOverflow is not a user help forum. It is more as a resource of good questions with answers to help future readers. It would be highly unlikely that a future reader to have both different problems at the same time and find this question in a search. – drescherjm Sep 30 '16 at 13:50
  • @drescherjm Got it, thank you so much. – user2187070 Oct 03 '16 at 02:23

0 Answers0