The C language Restricted area program itself deletes itself? It's time to show the real technology of the self-removal

Source: Internet
Author: User

Objective

self-deletion: as the name implies, this program function is very simple, is to implement the program's self-deletion function.

is not feeling very confused, a program runs on its own, how to shut itself down, and then delete it? By the time you finish your process, you will end up and no longer execute any code. When the program executes, the file is open, and it cannot be deleted. is not to think, ah, can not think of the right.

If you can't figure it out, look for the mirror.

implementation principle

The program creates a batch file, and create the process execution, and then the program ends the process, the function of the batch is to delay 5 seconds after the deletion of the specified program and then self-delete. In this way, the program self-deletion function is implemented. Small series recommended a learning C language/c++ study Skirt "627, 012, four xxx", whether you are Daniel or small white, is to change careers or want to join the study together to learn about progress together! The skirt has the development tool, many dry goods and the technical information to share!

Is it very simple, I'll bring you to realize it

Test case

1. Test Case procedure

It's a Hello world.

2. Batch self-deleting files

    • delay 5 seconds

    • Delete the specified file

    • Delete batch itself

Code snippet:

    • data member Definitions:

    • Constructing a batch file path

    • To generate a batch file

    • To create a new process Execution cmd command

All right, that's what this whole thing looks like.

I have a public number, often share some of the C language/c++ technology related dry goods; If you like my share, you can use the search "C language learning Tribe" to focus on
Welcome to join thousands of people to exchange questions and answers skirt: 627+012+464


The C language Restricted area program itself deletes itself? It's time to show the real technology of the self-removal

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.