C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28691
Number of posts: 94711

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
how to make self destructive exe's Posted by srihari_cit on 9 Dec 2001 at 8:50 AM
how to make an exe file using C program so that
it destroys itself after 10 days . i mean a trial version
Report
Re: how to make self destructive exe's Posted by premnikam on 9 Dec 2001 at 9:18 AM
: how to make an exe file using C program so that
: it destroys itself after 10 days . i mean a trial version
:

Ask kunthavai or renuga. I think they will give the right ans


Report
Re: how to make self destructive exe's Posted by jeffpost on 9 Dec 2001 at 12:23 PM
: how to make an exe file using C program so that
: it destroys itself after 10 days . i mean a trial version
:
A simple way is to use findfirst() to get the ffblk structure (which contains the file's date), then use ftime to get the current time, compare the two, and if current time is more than 10 days later than the file's time, use remove() to delete the file. This is unreliable however, because someone can always modify the file's time using touch or some other method. The argument for findfirst() can be gotten from argv[0].

Report
Re: how to make self destructive exe's Posted by AsmGuru62 on 10 Dec 2001 at 8:04 AM
: : how to make an exe file using C program so that
: : it destroys itself after 10 days . i mean a trial version
: :
: A simple way is to use findfirst() to get the ffblk structure (which contains the file's date), then use ftime to get the current time, compare the two, and if current time is more than 10 days later than the file's time, use remove() to delete the file. This is unreliable however, because someone can always modify the file's time using touch or some other method. The argument for findfirst() can be gotten from argv[0].
:
:
This, probably, will not work in Windows - you can't delete an EXE file which is running.

Report
Re: how to make self destructive exe's Posted by weicco on 10 Dec 2001 at 8:07 AM
: : : how to make an exe file using C program so that
: : : it destroys itself after 10 days . i mean a trial version
: : :
: : A simple way is to use findfirst() to get the ffblk structure (which contains the file's date), then use ftime to get the current time, compare the two, and if current time is more than 10 days later than the file's time, use remove() to delete the file. This is unreliable however, because someone can always modify the file's time using touch or some other method. The argument for findfirst() can be gotten from argv[0].
: :
: :
: This, probably, will not work in Windows - you can't delete an EXE file which is running.
:
:

Could program create visual basic script that is stored in startup folder which on next boot would delete file?
Report
Re: how to make self destructive exe's Posted by LioLick on 10 Dec 2001 at 9:11 AM

: Could program create visual basic script that is stored in startup folder which on next boot would delete file?
:
I've think about it.
Try that: write a prog like delete.exe, which erase Your program from disk. Then, put a registry key in HKLM/Software/Microsoft/Windows/Current Version/RunOnce with value ="Path to delete.exe (e.g. c:/Yourprogs/delete.exe)"
It will run once after rebooting and will erase Your trial version.
I'hope, You understand me. My English is not very
Report
Re: how to make self destructive exe's Posted by jeffpost on 10 Dec 2001 at 11:45 AM
: This, probably, will not work in Windows - you can't delete an EXE file which is running.
:
:
This works just fine on Windows 98. Don't know about NT or 2000 since I don't have access to those (and I wouldn't use XP if you paid me).

#include <stdio.h>
#include <dir.h>
#include <dos.h>

int main(int argc, char *argv[])
{
int i;
struct ffblk finfo;

printf("\nfile name: %s\n", argv[0]);
i = findfirst(argv[0], &finfo, 0);
if (!i)
{
i = remove(argv[0]);
if (!i)
printf("file removed\n");
else
printf("\nCan't remove file %s\n", argv[0]);
}
else
printf("\nCan't find file %s\n", argv[0]);

return(0);
}


Report
Re: how to make self destructive exe's Posted by guilty on 11 Dec 2001 at 1:28 AM
Hi Guy ! I don't know 'bout the other compilers ,but I feel that This kinda Thing can be done in C .You first get the name of the program itself by command line arguments . use void main(int argc ,char **argv) instead of void main() argv[0] is the name of the program itself .Then after execution , you can use unlink() or remove() etc.. to delete the file you want .... !
Karthik Kumar V




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.