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 capacity in vector in c++?
Do you know what are the new features that iso/ansi c++ has added to original c++ specifications?
write a function signature with various number of parameters.
What are literals in C++?
How do you establish an is-a relationship?
When are exception objects created?
How do you show the declaration of a virtual constructor?
What is buffering in c++?
Describe exception handling concept with an example?
What are static variables?
What are maps in c++?
Describe new operator and delete operator?
What is function overloading c++?
what is upcasting in C++?
Describe new operator?