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
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?
What are advantages of using friend classes?
Why is polymorphism useful?
Explain selection sorting. Also write an example.
What ANSI C++ function clears the screen a) clrscr() b) clear() c) Its not defined by the ANSI C++ standard
What is constructor in C++?
How can you quickly find the number of elements stored in a static array? Why is it difficult to store linked list in an array?
Describe private, protected and public?
Can a list of string be stored within a two dimensional array?
Explain one method to process an entire string as one unit?
Explain what are mutator methods in c++?
How a pointer differs from a reference?
Do you know what is overriding?
What is constructor and destructor in c++?
Explain object slicing in c++?