Doscommand calling in C ++ (3) -- I do not advocate the extensive use of doscommands

Source: Internet
Author: User

Although I personally think that the doscommand has its merits and I have tried to better integrate it into the MFC program, I personally do not advocate a lot of use of the doscommand, after all, it is difficult to modify a lot of things using the doscommand, And the DOS versions are different, and many Microsoft-specific DoS enhanced commands make the program portability much worse, it is very important that too many DOS commands are used. For those who have learned only C ++ but have never experienced the DOS era, it is simply a book. Besides, not everyone wants to learn dos that way, but Windows API users will feel that it is no harm to know more about DOS. In addition, most doscommands have related Windows Programming solutions. For example, Microsoft provides a class library or APIs for you to solve the tasks that can be completed by the doscommand, and I proposed the doscommand at the beginning, because it is called using char *, debugging is much more difficult. In many cases, only one cmd window can be opened for one attempt. The problem is, sometimes there is no way to take it into account in various situations, so there is a possibility of a mysterious bug. Microsoft's class libraries and APIs are much better in this regard. Another point is that, as I demonstrated in the previous example, many command outputs of the doscommand are to output information on the screen, such as Dir, so there will be a lot of additional information, as a result, you need to get the required information through some conversions. In the previous example, I used regular expressions to complete these tasks. Although this is easier than the general method, but it is still complicated, and class libraries and APIs can directly obtain the required information, which is also their advantage.

Of course, what I want to talk about is not how scared to use DOS commands, and I personally regard the programs that call command lines as an extended form of DOS commands, it can be used as a supplement for further understanding of Windows APIs. In some cases, a DOS command may only require one step of functionality to implement, but may require many lines of programs. In addition, some good command-line programs compiled by others can be used to add some functions that are hard to implement for their own programs. Here, I provide several doscommands that I personally think are worth using:

FC, COMP: Compare files

Ping: Needless to say

Regedit/E: Export registry Regedit/L: Import Registry

Xcopy: it is easier to copy files and directory trees than shfileoperation.

Deltree: delete a directory, which is easier to use than shfileoperation.

Proxycfg, finger, tracert, ipconfig,Route, trance, netstat, net, FTP, telnet: it is estimated that it is not so easy to implement their functions through general programming, however, it would be much easier to use the command line program provided by windows. In fact, because I am not very familiar with network programming, I feel that using the network-related programs provided by Windows will make the implementation of some network functions much easier. If I am proficient in network programming, I still don't know whether this is the case.

At: Plan

Shutdown

Tskill: end the process

We also recommend the pstools tool group and the command line version RAR and unrar of WinRAR. With them, you can easily compress and decompress the program without learning how to call the library. Basically; that's it. I will add something later.

 

 


 

Related Article

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.