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 operators in c++?
What is lazy initialization in c++?
What is near, far and huge pointers? How many bytes are occupied by them?
Why do we use iterators?
What are compilers in c++?
Define upcasting.
What kind of problems can be solved by a namespace?
Why do we use using namespace std in c++?
How do c++ struct differs from the c++ class?
What is data hiding c++?
Can we declare a base-class destructor as virtual?
What is the object serialization?
What is dynamic and static typing?
How do you initialize a string in c++?
What is vector pair in c++?