-
Sep 1st, 2005, 10:37 AM
#1
Thread Starter
Fanatic Member
tell how many times app is run (resolved)
hi i was wondering how i would go about (in code) telling how many times my app has been run almost like a trial thing where after so many times the program stops workin untli you buy the full thing that type of idea
Last edited by dark_shadow; Sep 3rd, 2005 at 09:36 PM.
-
Sep 1st, 2005, 10:44 AM
#2
Fanatic Member
Re: tell how many times app is run
You'd probably have to store that information outside of your program in a text file or better the registry.
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
-
Sep 1st, 2005, 10:46 AM
#3
Thread Starter
Fanatic Member
Re: tell how many times app is run
that's what i was also thinking but i was hopping there was another way thanks anyway
-
Sep 1st, 2005, 10:47 AM
#4
Re: tell how many times app is run
in form load:
VB Code:
Dim NumOfRuns as integer
NumOfRuns = Val(Getsetting("APPNAME","DATA","RUNS","0"))
NumOfRuns = NumOfRuns + 1
SaveSetting "APPNAME", "DATA", "RUNS", NumOfRuns
'Check for too many...
if NumOfRuns > 15 then Msgbox "You have run this more than 15 times"
'etc..
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Sep 1st, 2005, 10:47 AM
#5
Re: tell how many times app is run
Originally Posted by space_monkey
You'd probably have to store that information outside of your program in a text file or better the registry.
A text file would be too easy to delete or modify, so I'd go with the registry.
Of course, each time your program ran, it would have to read this information and make a determination on whether it should continue. This would require that you have some limit hardcoded into your FormLoad event with which it can make a comparison.
-
Sep 1st, 2005, 11:55 AM
#6
Thread Starter
Fanatic Member
Re: tell how many times app is run
thanks for the input guys. [LGS]Static, the code worked perfect thank you
-
Sep 1st, 2005, 11:58 AM
#7
Re: tell how many times app is run
Originally Posted by dark_shadow
thanks for the input guys. [LGS]Static, the code worked perfect thank you
Is this for a demo of a program that you hope to market and sell?
If so, good luck!
-
Sep 1st, 2005, 12:15 PM
#8
Thread Starter
Fanatic Member
Re: tell how many times app is run
i dunno yet the thing is that when i give my freinds any little prog i make i tell then not 2 go and give it 2 people and what do they do ...they give it 2 people so its kinda a security that after so many times it will stop working and they will have 2 talk me about it
-
Sep 1st, 2005, 06:01 PM
#9
Addicted Member
Re: tell how many times app is run (resolved)
Why not create a hash key....
My applications I make do this:
Grab drive serial number, grab windows serial number, plus another hash (I've done by a year). So each year the user has to request a new serial number to use the product... good for getting more money.
Anways, I have a key generator with the same hash code, then all the user does is copy/paste the code you have given them and if it is correct let them use the program, write the key-code to the registry and have the program check it everytime it is run. This is prob the best cost effective method I've chosen because I know exactly who uses the product. There serial number shouldn't change upon re-install of windows (if same disk), if on the same system (same Drive).... This would be the best method for you because if someone wants it on their computer, they copy the app, and have to request the key number via their friend. The registry is too easy to modify and can simply reset if they are a mindful person...
Another easy alternative is to create a file in the system32 folder of windows... name it something ambigious that you would consider a critical system file (so it wouldn't be deleted) and simply store a single value of the times it's been used. Update it upon opening the program... Another simple trick that can be used
If your interested in the later explanation search the board, there are plenty of good examples which I've incorperated in my projects.
-
Sep 1st, 2005, 08:53 PM
#10
Thread Starter
Fanatic Member
Re: tell how many times app is run (resolved)
yes but the people that he's giving it 2 are dumbasses at computers they were amazed that when they clicked beside the button a message box came up and said " click the button not around it " so i doubt they will be editing the regestry any time soon
-
Sep 2nd, 2005, 03:05 PM
#11
Thread Starter
Fanatic Member
Re: tell how many times app is run
alright another problem ... how do i get it to reset back to the default?
-
Sep 2nd, 2005, 03:10 PM
#12
Fanatic Member
Re: tell how many times app is run
If you are using this
VB Code:
SaveSetting "APPNAME", "DATA", "RUNS", NumOfRuns
just
VB Code:
if YOUR_REASON = true then
SaveSetting "APPNAME", "DATA", "RUNS", 0
end if
I think that will work.
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
-
Sep 2nd, 2005, 03:17 PM
#13
Thread Starter
Fanatic Member
Re: tell how many times app is run
it didnt work
VB Code:
'heres what i've got in the form load
Dim NumOfRuns As Integer
NumOfRuns = Val(GetSetting("APPNAME", "DATA", "RUNS", 0))
NumOfRuns = NumOfRuns + 1
SaveSetting "APPNAME", "DATA", "RUNS", NumOfRuns
'Check for too many...
If NumOfRuns > 40 Then MsgBox "You have run this more than 40 times the application will now be frozen until you contact the creator"
lock_all 'locks form
and in the buttion u click 2 unlock it
VB Code:
If text1.Text = "tainteddark1989" Then
SaveSetting "APPNAME", "DATA", "RUNS", 0
unock_all 'unlocks form
End If
End Sub
-
Sep 2nd, 2005, 03:27 PM
#14
Re: tell how many times app is run
You can make it even more difficult for the user to hide the info with an ADS file: VB - How to use Alternate Data Stream files
An ADS file is more difficult to find than a key in the registry...
-
Sep 2nd, 2005, 03:27 PM
#15
Re: tell how many times app is run
Does it keep increasing the runs in the registry?
Is it on the same form as the textbox, or do you need form.textbox in the IF statement?
-
Sep 2nd, 2005, 03:31 PM
#16
Thread Starter
Fanatic Member
Re: tell how many times app is run
its on the same form as the textbox and no it dosent keep them in the regestry
-
Sep 2nd, 2005, 03:48 PM
#17
Re: tell how many times app is run
Here it is from online help:
SaveSetting Statement Example
The following example first uses the SaveSetting statement to make entries in the Windows registry (or .ini file on 16-bit Windows platforms) for the MyApp application, and then uses the DeleteSetting statement to remove them.
' Place some settings in the registry.
SaveSetting appname := "MyApp", section := "Startup", _
key := "Top", setting := 75
SaveSetting "MyApp","Startup", "Left", 50
' Remove section and all its settings from registry.
DeleteSetting "MyApp", "Startup"
and this
GetSetting Function Example
This example first uses the SaveSetting statement to make entries in the Windows registry (or .ini file on 16-bit Windows platforms) for the application specified as appname, and then uses the GetSetting function to display one of the settings. Because the default argument is specified, some value is guaranteed to be returned. Note that section names can't be retrieved with GetSetting. Finally, the DeleteSetting statement removes all the application's entries.
' Variant to hold 2-dimensional array returned by GetSetting.
Dim MySettings As Variant
' Place some settings in the registry.
SaveSetting "MyApp","Startup", "Top", 75
SaveSetting "MyApp","Startup", "Left", 50
Debug.Print GetSetting(appname := "MyApp", section := "Startup", _
key := "Left", default := "25")
DeleteSetting "MyApp", "Startup"
-
Sep 2nd, 2005, 03:59 PM
#18
Thread Starter
Fanatic Member
Re: tell how many times app is run
every time i do this i get a "varible not defined" error and when i dim it it gives me a wrong amount of arguments error
-
Sep 2nd, 2005, 04:04 PM
#19
Fanatic Member
Re: tell how many times app is run
Where are you getting that error at?
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
-
Sep 2nd, 2005, 04:11 PM
#20
Re: tell how many times app is run
What variable? What line?
-
Sep 2nd, 2005, 04:50 PM
#21
Thread Starter
Fanatic Member
Re: tell how many times app is run
on the line
VB Code:
DeleteSettings "APPNAME", "DATA", "RUNS", [COLOR=Red]NumofRuns[/COLOR]
NumofRuns gives me a varible not defined error and when i dim it
VB Code:
[COLOR=Magenta]dim NumofRuns as Integer[/COLOR]
DeleteSettings "APPNAME", "DATA", "RUNS", NumofRuns
it says "invalid number of arguments"
Last edited by dark_shadow; Sep 2nd, 2005 at 04:54 PM.
-
Sep 2nd, 2005, 05:26 PM
#22
Re: tell how many times app is run
Just use this:
VB Code:
DeleteSettings "APPNAME", "DATA", "RUNS"
-
Sep 2nd, 2005, 05:37 PM
#23
Thread Starter
Fanatic Member
Re: tell how many times app is run
it still dosent seem to work
VB Code:
Private Sub mnuunlock_Click()
DeleteSettings "APPNAME", "DATA", "RUNS"
unock_all'unlocks the buttons on the form
End Sub
is this correct? i keep getting a varible not defined error for the DeleteSettings
-
Sep 2nd, 2005, 05:53 PM
#24
Re: tell how many times app is run
Oops. KIM that this removes ALL settings from the key
VB Code:
DeleteSettings "APPNAME", "DATA"
-
Sep 2nd, 2005, 06:11 PM
#25
Thread Starter
Fanatic Member
Re: tell how many times app is run
still no go i keep gettin the same error
VB Code:
Private Sub mnuunlock_Click()
DeleteSettings "APPNAME", "DATA",
unock_all'unlocks the buttons on the form
End Sub
Last edited by dark_shadow; Sep 2nd, 2005 at 06:15 PM.
-
Sep 2nd, 2005, 06:20 PM
#26
Re: tell how many times app is run
What error do you get? You dont need (cant have) the comma at the end.
DeleteSettings "APPNAME", "DATA",
It should be
DeleteSettings "APPNAME", "DATA"
-
Sep 2nd, 2005, 06:20 PM
#27
Re: tell how many times app is run
Originally Posted by dark_shadow
still no go i keep gettin the same error
VB Code:
Private Sub mnuunlock_Click()
DeleteSettings "APPNAME", "DATA",
unock_all'unlocks the buttons on the form
End Sub
How about removing the comma at the end of this line:
VB Code:
DeleteSettings "APPNAME", "DATA"[b],[/b]
-
Sep 2nd, 2005, 06:50 PM
#28
Thread Starter
Fanatic Member
Re: tell how many times app is run
even with removing the comma it still doesn not work when i goto run the program again it still has everything locked
-
Sep 2nd, 2005, 07:14 PM
#29
Re: tell how many times app is run
Don't you have a setting to compare to that tells the app that it's unlocked?
If you delete the registry key, are you checking for it when the program starts?
You may have to post some more code.
I would leave the key with 40 runs in it, and keep count of the times it was run
Create a file to unlock the app, and check if it exists. If the count = 40 and the file isn't found, then they can't run the program. If the file exists then the count doesn't matter.
You could also use another registry key instead of a file.
-
Sep 2nd, 2005, 07:18 PM
#30
Thread Starter
Fanatic Member
Re: tell how many times app is run
alright i get it but how exactely would i check for it ?
-
Sep 2nd, 2005, 07:24 PM
#31
Re: tell how many times app is run
This pseudo code of what you shoud do:
VB Code:
Dim Count As Integer
Count = GetSettings ("APPNAME", "Count")
If Count < 40 Then
Count = Count + 1
SetSettings "APPNAME", "Count", Count
Else
'Terminate application
End If
-
Sep 2nd, 2005, 07:28 PM
#32
Re: tell how many times app is run
To unlock:
VB Code:
dim ff as integer
open app.path & "\unlock.txt" for output as #ff
print #ff, "unlocked"
close #ff
To load:
VB Code:
If Dir(app.path & "\unlock.txt" ) = "" then ' Not found
' read count into registry
if regcnt > 40 then
msgbox "Time trial is up!"
unload me
endif
endif
-
Sep 2nd, 2005, 08:59 PM
#33
Thread Starter
Fanatic Member
Re: tell how many times app is run
VB Code:
dim ff as integer
open app.path & "\unlock.txt" for output as #ff
print #ff, "unlocked"
close #ff
on this code i'm getting a "bad file name or number error"
-
Sep 2nd, 2005, 09:03 PM
#34
Re: tell how many times app is run
Oops. That's what I get for free-handing it.
VB Code:
dim ff as integer
[COLOR=Red]ff = freefile[/COLOR]
open app.path & "\unlock.txt" for output as #ff
print #ff, "unlocked"
close #ff
-
Sep 2nd, 2005, 09:16 PM
#35
Thread Starter
Fanatic Member
Re: tell how many times app is run
alright so i'm suppost 2 put this
VB Code:
If Dir(app.path & "\unlock.txt" ) = "" then ' Not found
' read count into registry
if regcnt > 40 then
msgbox "Time trial is up!"
unload me
endif
endif
in a differnt prog to check it?
-
Sep 2nd, 2005, 09:20 PM
#36
Re: tell how many times app is run
No, just put it in your main form_activate section, and it will fire when the program opens. If the file is found, all is good. If the file isn't found, then have it check the registry settings to see if it been executed 40 times. If not, add one, and let them use it again. If it has, show a message, and unload the form, which will end the app.
-
Sep 2nd, 2005, 09:28 PM
#37
Thread Starter
Fanatic Member
Re: tell how many times app is run
VB Code:
If Dir(app.path & "\unlock.txt" ) = "" then ' Not found
' read count into registry
if [COLOR=Red]regcnt[/COLOR] > 40 then
msgbox "Time trial is up!"
unload me
endif
endif
ok i keep getting a "varible not defined error"
-
Sep 2nd, 2005, 09:38 PM
#38
Re: tell how many times app is run
Originally Posted by dark_shadow
VB Code:
[COLOR=Blue]dim regcnt as long[/COLOR]
If Dir(app.path & "\unlock.txt" ) = "" then ' Not found
' read count into registry
[COLOR=Blue] regcnt = Val(GetSetting("APPNAME", "DATA", "RUNS", 0))[/COLOR]
if [COLOR=Red]regcnt[/COLOR] > 40 then
msgbox "Time trial is up!"
unload me
endif
endif
I left that out, thinking that you would insert the same code that you use to read RUNS. I think this is it, but am not sure. Make Sure that you add one and write it back after that code so you can keep track of RUNS.
Add the blue lines
-
Sep 2nd, 2005, 10:05 PM
#39
Thread Starter
Fanatic Member
Re: tell how many times app is run
i finally figured out a way to fix it i was actually insulted i didnt do this before
this is all i did
VB Code:
Private Sub mnuunlock_Click()
Dim NumOfRuns As Integer
NumOfRuns = Val(GetSetting("APPNAME", "DATA", "RUNS", 0))
' minus 40 therefor setting the value at 0 again
NumOfRuns = NumOfRuns - 40
SaveSetting "APPNAME", "DATA", "RUNS", NumOfRuns
End Sub
so far its works
thank you so much for the input it is greatly appricated
-
Sep 2nd, 2005, 10:44 PM
#40
Re: tell how many times app is run
That's good. Glad you're happy.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|