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
How do I tokenize a string in c++?
Is dev c++ a good compiler?
What are virtual functions in c++?
What is std namespace in c++?
Write a function to perform the substraction of two numbers. Eg: char N1="123", N2="478", N3=-355(N1-N2).
List different attributes in C++?
Is c++ built on c?
What are guid?
What is increment operator in c++?
Can char be a number c++?
What is the type of 'this' pointer?
Describe the role of the c++ in the tradeoff of safety vs. Usability?
What are static variables?
What is the difference between multiple and multilevel inheritance in c++?
Write about the local class and mention its use?