自我删除.exe [英] self deletable .exe

查看:49
本文介绍了自我删除.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1.如何制作自己删除的.exe文件,以便在运行时文件从当前路径中删除

本身。

plz answer,

感谢advence。

再见。

1.How to make self deletable .exe file such that during runtime the file delete
itself from the current path.
plz answer,
thanks in advence.
bye.

推荐答案

ROSY< de ******** ******@rediffmail.com>潦草地写下:
ROSY <de**************@rediffmail.com> scribbled the following:
1.如何制作自删除的.exe文件,以便在运行时文件从当前路径中删除。
1.How to make self deletable .exe file such that during runtime the file delete
itself from the current path.



#include< stdio.h>

#include< string.h>

int main(void){

char buffer [100];

printf("这个.exe文件的名称是什么?\ n");

fgets(buffer,sizeof buffer, stdin);

if(buffer [strlen(buffer)-1] ==''\ n'')

buffer [strlen(buffer)-1] = ''\''';

删除(缓冲区);

返回0;

}


-

/ - Joona Palaste(pa*****@cc.helsinki.fi)------------------ --------- \

| 飞翔的柠檬树中的金鸡王G ++ FR FW + M-#108 D + ADA N +++ |

| http://www.helsinki.fi/~palaste W ++ B OP + |

\ -----------------------------------------芬兰的规则! ------------ /

记住:只有三种人 - 那些可以计算的人和那些可以'b
'的人't。"

- Vampyra



#include <stdio.h>
#include <string.h>
int main(void) {
char buffer[100];
printf("What is the name of this .exe file?\n");
fgets(buffer, sizeof buffer, stdin);
if (buffer[strlen(buffer)-1] == ''\n'')
buffer[strlen(buffer)-1] = ''\0'';
remove(buffer);
return 0;
}

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"Remember: There are only three kinds of people - those who can count and those
who can''t."
- Vampyra


位缩短并输入错误..

; - )


< code>

#include< stdio.h>

#include< string.h>

int main(int argc,char ** argv)

{

remove(* argv);

return 0; < br $>
}

< / code>


PS:你的问题听起来很像家庭作业......


2003年9月17日08:08:14 GMT

Joona I Palaste< pa ***** @ cc.helsinki.fi>写道:
bit shorter and typo save ..
;-)

<code>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
remove(*argv);
return 0;
}
</code>

PS: your questions sounds lot like homework...

On 17 Sep 2003 08:08:14 GMT
Joona I Palaste <pa*****@cc.helsinki.fi> wrote:
ROSY< de ************** @ rediffmail.com>潦草地写道:
ROSY <de**************@rediffmail.com> scribbled the following:
1.如何制作自删除的.exe文件,以便在运行时将
文件从当前路径中删除。
1.How to make self deletable .exe file such that during runtime the
file delete itself from the current path.


#include< stdio.h>
#include< string.h>
int main(void){
char buffer [100];
printf("什么是.exe文件的名称?\ n");
fgets(buffer,sizeof buffer,stdin);
if(buffer [strlen(buffer)-1] ==''\ n'')
缓冲区[strlen(buffer)-1] =''\ 0'';
删除(缓冲区);
返回0;
}

-
/ - Joona Palaste(pa*****@cc.helsinki.fi)
---------------- ----------- \ | 飞行的柠檬树的国王G ++ FR FW + M-#108 D + ADA N +++ || http://www.helsinki.fi/~palaste
W ++ B OP +
| \ -----------------------------------------芬兰的规则!
------------ /记住:只有三种人 - 那些可以数数的人和那些无法计算的人。
- Vampyra



#include <stdio.h>
#include <string.h>
int main(void) {
char buffer[100];
printf("What is the name of this .exe file?\n");
fgets(buffer, sizeof buffer, stdin);
if (buffer[strlen(buffer)-1] == ''\n'')
buffer[strlen(buffer)-1] = ''\0'';
remove(buffer);
return 0;
}

--
/-- Joona Palaste (pa*****@cc.helsinki.fi)
---------------------------\| Kingpriest of "The Flying Lemon Tree"
G++ FR FW+ M- #108 D+ ADA N+++|| http://www.helsinki.fi/~palaste
W++ B OP+
|\----------------------------------------- Finland rules!
------------/"Remember: There are only three kinds of people - those
who can count and those who can''t."
- Vampyra



" Joona I Palaste" < PA ***** @ cc.helsinki.fi>发表了回复:
"Joona I Palaste" <pa*****@cc.helsinki.fi> posted a reply:
ROSY< de ************** @ rediffmail.com>潦草地写道:
ROSY <de**************@rediffmail.com> scribbled the following:
1.如何制作自删除的.exe文件,以便在运行时将
文件从当前路径中删除。
#include< stdio.h> ;
#include< string.h>
int main(void){
char buffer [100];
printf("这个.exe文件的名称是什么?\ n");
fgets(buffer,sizeof buffer,stdin);
if(buffer [strlen(buffer)-1] ==''\ n'')
1.How to make self deletable .exe file such that during runtime the
file delete itself from the current path.
#include <stdio.h>
#include <string.h>
int main(void) {
char buffer[100];
printf("What is the name of this .exe file?\n");
fgets(buffer, sizeof buffer, stdin);
if (buffer[strlen(buffer)-1] == ''\n'')




这里有未定义的行为,如果fgets返回一个空指针(因为缓冲区

将是未初始化或不确定的,因此strlen的输入无效)。

buffer [strlen(buffer)-1] =''\ 0'';
remove(buffer);


您应该检查删除是否成功。在许多系统上,一个文件在执行时被锁定,并且无法删除。

if(remove(buffer)!= 0)

{

printf(无法删除file.\ n);

}

返回0;
}



Undefined behaviour here if fgets returned a null pointer (because buffer
would be uninitialised or indeterminate, and so invalid input for strlen).
buffer[strlen(buffer)-1] = ''\0'';
remove(buffer);
You should check whether the remove succeeded. On many systems a file is
locked while it is executing and cannot be removed.
if(remove(buffer) != 0)
{
printf("Unable to remove file.\n");
}
return 0;
}




-

Simon。



--
Simon.


这篇关于自我删除.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆