I made a project (exe). I want when a user use it , after 6 month or 1 year it will expired. I mean the exe is use for 1 year. after 1 year it will show a msg. like: demo version for 1 year. contact with author.

Recommended Answers

All 19 Replies

For the most simplistic version you could check the creation date of some file you created against the now function, do a date diff based on "d" (day) and if >= 365 display message/shutdown program. However, user could get around this by resetting the date time on the machine. Same goes for using the registry or placing date info in some file.

Now, what may be harder for the user to get around is a count of how many times your program has run as you could hide this count in the registry, in a file, and if you wanted you could attach it to a file on an NTFS drive as in adding a property to a file. Then you could check the count in all three places and see if use has tampered with anyone of the counts. More than likely, a determined user would find the registry setting, file contents, but once they found that file, would they check the properties of that file?

No, real guarenteed way, but many different ways.

Good Luck

>> do a date diff based on "d" (day) and if >= 365 display message/shutdown program.


Please help me with code. and details

Type in datediff and press F1 and do the same for Open, SaveSetting, GetSetting, and then search the web for examples on the API's CreateFile and GetFileTime.

Good Luck

hope this helps!
add a textbox

Private Sub Form_Load()
Text1.Text = ""
Dim f As Integer
Dim s As String
  
  'load the whole file into a string variable
  f = FreeFile()
  Open "C:\windows\system32\date.txt" For Binary As #f
  s = Space$(LOF(f))
  Get #f, , s
  Text1.Text = s
  If Text1.Text = "" Then 'if there isn't anything in the textfile then put the date in
  Close #f
  
  Text1.Text = Date
  'do the modifications here
  'save the string variable into the file
  Kill "C:\windows\system32\date.txt"
  f = FreeFile()
  Open "C:\windows\system32\date.txt" For Binary As #f 'put date in file
  Put #f, , Text1.Text
  Close #f
ElseIf DateDiff(d, Text1.Text, Date) > 364 Then 'if there is a difference between files date and curente date of 365 or more
' then do something
MsgBox "hi"
End If

End Sub

this msg show:
run time error '5'
Invalid procedure call or argument

now what I do?

Try this

Private Sub Form_Load()
Text1.Text = ""
Dim f As Integer
Dim s As String
Dim dy
  
  'load the whole file into a string variable
  f = FreeFile()
  Open "C:\windows\System32\date.txt" For Binary As #f
  s = Space$(LOF(f))
  Get #f, , s
  Text1.Text = s
  If Text1.Text = "" Then 'if there isn't anything in the textfile then put the date in
  Close #f
  
  Text1.Text = Date
  'do the modifications here
  'save the string variable into the file
  Kill "C:\windows\system32\date.txt"
  f = FreeFile()
  Open "C:\windows\system32\date.txt" For Binary As #f 'put date in file
  Put #f, , Text1.Text
  Close #f
  
  dy = DateDiff(D, Text1.Text, Date)
ElseIf dy > 364 Then  'if there is a difference between files date and curente date of 365 or more
' then do something
MsgBox "hi"
End If

End Sub

hi crackerjacker

now that msg not show. but when I change my computer date more 365 days now the msg not show like 'hi'. the text box show the that date when I start the program.

put the date constant inside your code.

CONST dateExpired = "2010-APR-13";

everytime your program runs....detect the user computer time now();

then do the comparison if dateExpired > now() okay if not...create an error.

rm_daniweb
if you don't mind please modify the code what write by crackerjacker .

rm_daniweb
if you don't mind please modify the code what write by crackerjacker .

Private Sub Form_Load()
Dim ExpiryDate As Date
ExpiryDate = "14-04-2009" 'your program expiration date
If Now() > ExpiryDate Then MsgBox "THIS PROGRAM EXPIRED": Exit Sub Else MsgBox "CONTINUE..."
End Sub

this will detect the system time of their pc. if they return to 2008 the program still running so you have to create a self destruct after the expiration date reach by your program like deleting some dll or ocx or change the content of one dll and ocx writing destruction code inside your file.

change the content of one dll and ocx writing destruction code inside your file.

can you give me more details

can you give me more details

I know you know how to open files and append, delete content on it.

OPEN "MYLIB.DLL" FOR BINARY AS #1
[APPEND/DELETE]
WRITE # OR LINE INPUT# OR INPUT #
CLOSE

your dll or ocx was modified so it will not work anymore.

do you have dll or ocx in your code if you don't have look for some file dependencies that you can destroy.

Private Sub Form_Load()
Dim ExpiryDate As Date
ExpiryDate = "14-04-2009" 'your program expiration date
If Now() > ExpiryDate Then MsgBox "THIS PROGRAM EXPIRED": Exit Sub Else MsgBox "CONTINUE..."
End Sub

you fixed a date. but I want it auto create. when the exe 1st run it create the file with current date what said crackerjacker . how it work by your code? can you help me please?

you fixed a date. but I want it auto create. when the exe 1st run it create the file with current date what said crackerjacker . how it work by your code? can you help me please?

okay try this!

Private Sub Form_Load()
Text1.Text = ""
Dim f As Integer
Dim s As String
Dim dy As Variant ------------------------> I change this!!!
  
  'load the whole file into a string variable
  f = FreeFile()
  Open "C:\date.txt" For Binary As #f
  s = Space$(LOF(f))
  Get #f, , s
  Text1.Text = s
  If Text1.Text = "" Then 'if there isn't anything in the textfile then put the date in
  Close #f
  
  Text1.Text = Date
  'do the modifications here
  'save the string variable into the file
  Kill "C:\date.txt"
  f = FreeFile()
  Open "C:\date.txt" For Binary As #f 'put date in file
  Put #f, , Text1.Text
  Close #f
  
dy = DateDiff(D, Text1.Text, Date)
ElseIf dy < 3 Then  '-------------------> change the < to > to practice the result after 3 days
' then do something
MsgBox "Your program Expired!"
End If

End Sub

The problem with creating a file is that it may already exist. You have to make sure that when the program creates the file that it does not already exist. If it does then your program will either crash or a message will appear "Do you want to overwrite the file?". Better to have it in your own folder or a sub folder of your program. Having it in a system file may produce unexpected results especially if you are not the administrator.
If you use a folder that is not of your own making then you have to write code that checks for an existing file. If the file name exists, you have to have a backup filename you can use then check for that filename until there are no filenames that match your chosen name.
Now you have your Check-File, use an identifier mark in the first line so that everytime the program starts it can check for the identifier mark. If it doesn't exist then Msgbox "The program cannot proceed. A file or files cannot be found. Reinstall or contact blah blah" Exit and End.
Easiest way is to not use the .txt extension. Make your own extension that is not a System extension or a Program extension. Example: Goobers.flub or DontDeleteThis.dud Many people today are so wary of unknown file names that it is likely to get deleted or found anyway, no matter where you put it.
Better to have a set date based on the date the program was created as suggested by mm_daniweb. Every 8 months you can update the program and upload it to the site with a slightly modified name like MyProgram_02.exe
Many programmers are removing components for demo or trial products. This might be your only option. When a product is purchased in full then you provide the full working model.
There is no guarantee that your full working model will not be shared with friends and colleagues, or even over the internet. This is the reason why so many products cost so much. Software Developers have to recoup as much as possible befor the market is flooded with pirate copies.

Many programmers are removing components for demo or trial products. This might be your only option.

don't mind. I need a easy way. so I start this theard. help need.

I've just thought of something that might be the easiest solution.
You can write code to "see" the date of the program, ie DateModified or DateCreated, and then Datdiff current date from the applications' date.

If a user changes the system date on their computer, they may well end up with the Blue Screen of Death because system files rely on the current date set. If system files try to restore to a previous state and the date is before the system restore file were created this too will muck up everything. If people want to wreck their computers by changing the date to suit an application, then let them.

but this code not work properly. did you check it. If you check it then please modify it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.