How to write a program such that it will delete itself after
exectution?
Answer Posted / siva
this code is tested succesfully.
#include <windows.h>
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main(int arg, int argv[])
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
STARTUPINFO sj;
PROCESS_INFORMATION pj;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
ZeroMemory( &sj, sizeof(sj) );
sj.cb = sizeof(sj);
ZeroMemory( &pj, sizeof(pj) );
if(!CreateProcess("C:\\Windows\\system32
\\cmd.exe", "/k del C:\\testp.exe", NULL, NULL, FALSE, 0,
NULL, NULL, &sj, &pj))
{
printf( "Hello CreateProcess failed (%d)\n",
GetLastError() );
}
return 0;
}
| Is This Answer Correct ? | 2 Yes | 2 No |
Post New Answer View All Answers
What is encapsulation in C++? Give an example.
Explain the use of this pointer?
Why do we use double in c++?
Can I uninstall microsoft c++ redistributable?
How can an improvement in the quality of software be done by try/catch/throw?
Why do we use classes in c++?
Write a program in c++ to print the numbers from n to n2 except 5 and its multiples
Why cout is used in c++?
What is std namespace in c++?
Explain method of creating object in C++ ?
If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?
How many ways can a variable be initialized into in C++?
You want to link a c++ program to c functions. How would you do it?
Can char be a number c++?
What is setw manipulator in c++?