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 Destructor in C++?
Define a nested class.
What is #include iomanip?
Name the implicit member functions of a class.
What are the extraction and insertion operators in c++?
What is the difference between an external iterator and an internal iterator? Describe an advantage of the external iterator.
Is c++ vector a linked list?
Why cout is used in c++?
What is the difference between the parameter to a template and the parameter to a function?
What is a literal in c++?
Explain how would you handle a situation where you cannot call the destructor of a local explicitly?
Can comments be longer than one line?
What are the uses of static class data?
write a program that withdrawals,deposits,balance check,shows mini statement. (using functions,pointers and arrays)
How do you declare A pointer to a function which receives nothing and returns nothing