Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

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?

1453


What are advantages of using friend classes?

1017


Why is polymorphism useful?

1028


Explain selection sorting. Also write an example.

989


What ANSI C++ function clears the screen a) clrscr() b) clear() c) Its not defined by the ANSI C++ standard

987


What is constructor in C++?

1024


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?

947


Describe private, protected and public?

1048


Can a list of string be stored within a two dimensional array?

968


Explain one method to process an entire string as one unit?

1525


Explain what are mutator methods in c++?

1069


How a pointer differs from a reference?

1281


Do you know what is overriding?

1122


What is constructor and destructor in c++?

1065


Explain object slicing in c++?

1026