Write down the lesson. For the use of shfileoperation, use of the command line program

Source: Internet
Author: User

If you have been developing Windows, you can run it in Linux.ProgramThe usage of directories must be the same as that of me. The principle is very simple, because Linux does not support "/" and Windows supports "/", it has always been like this. The use of Linux native "/" is naturally no problem, fopen in windows, createfile, openfile, CreateProcess, and so on are not used once or twice, and there is no problem with the use. Of course, today, the problem is coming, and the debugging will be depressing.

 

About shfileoperation. No error returned for this damn FunctionCodeThe execution fails. getlasterror may return a number other than systemerror in msdn. So the nightmare began. When I use "/" as a regular expression of directories and test code, only one layer of directories can be used successfully, that is, E: /data directory execution is normal. But when the directory is very multi-layer, shfileoperation can also be successful, but sometimes it fails. I have repeatedly entered the parameter for verification. (It is worth noting that the input parameter ends with a double zero) until I crash. When you want to directly use CreateProcess to call commands such as copy/y and del to complete the task, you just remember that "/" is used to represent parameters in DOS (the so-called shell bar in Windows .... Using "/" to indicate a directory to call the doscommand will always fail ....... The name of sh... Shell ..... Everything is clear .... It should be noted that this is not described in msdn, and even if I use "/" to indicate the Directory and call shfileoperation, there is still a success .... In more cases, it is not a complete failure, and it is half done ....... It's too unreasonable, and there's no errorcode .......

 

In addition, we are looking for some decompressed libraries to complete the update operation in the monitoring system. I searched for the zlib, 7-zip support library, and so on one afternoon. If I found that RAR is not supported, the usage is unknown, or Linux is not supported. Finally, I found that it was not suitable, the unrar command line tool can actually complete the task ....... It's nothing more than a familiar CreateProcess. I'm amazed that I wrote a series of articles for the doscommand, I forgot it when I got to the project application .... In fact, sometimes it is much easier to use a command line tool than to find a library ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.