PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
tell how many times app is run (resolved)-VBForums
Results 1 to 40 of 40

Thread: tell how many times app is run (resolved)

  1. #1

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Resolved 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.

  2. #2
    Fanatic Member space_monkey's Avatar
    Join Date
    Apr 2005
    Location
    神と歩くこと
    Posts
    573

    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

  3. #3

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    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

  4. #4
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: tell how many times app is run

    in form load:
    VB Code:
    1. Dim NumOfRuns as integer
    2. NumOfRuns = Val(Getsetting("APPNAME","DATA","RUNS","0"))
    3. NumOfRuns = NumOfRuns + 1
    4. SaveSetting "APPNAME", "DATA", "RUNS", NumOfRuns
    5. 'Check for too many...
    6. if NumOfRuns > 15 then Msgbox "You have run this more than 15 times"    
    7. 'etc..
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: tell how many times app is run

    Quote 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.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  6. #6

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: tell how many times app is run

    thanks for the input guys. [LGS]Static, the code worked perfect thank you

  7. #7
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: tell how many times app is run

    Quote 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!
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  8. #8

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    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

  9. #9
    Addicted Member
    Join Date
    Jun 2005
    Posts
    192

    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.

  10. #10

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    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

  11. #11

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: tell how many times app is run

    alright another problem ... how do i get it to reset back to the default?

  12. #12
    Fanatic Member space_monkey's Avatar
    Join Date
    Apr 2005
    Location
    神と歩くこと
    Posts
    573

    Re: tell how many times app is run

    If you are using this

    VB Code:
    1. SaveSetting "APPNAME", "DATA", "RUNS", NumOfRuns

    just

    VB Code:
    1. if YOUR_REASON = true then
    2.       SaveSetting "APPNAME", "DATA", "RUNS", 0
    3. 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

  13. #13

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: tell how many times app is run

    it didnt work

    VB Code:
    1. 'heres what i've got in the form load
    2. Dim NumOfRuns As Integer
    3. NumOfRuns = Val(GetSetting("APPNAME", "DATA", "RUNS", 0))
    4. NumOfRuns = NumOfRuns + 1
    5. SaveSetting "APPNAME", "DATA", "RUNS", NumOfRuns
    6. 'Check for too many...
    7. If NumOfRuns > 40 Then MsgBox "You have run this more than 40 times the application will now be frozen until you contact the creator"
    8. lock_all 'locks form

    and in the buttion u click 2 unlock it
    VB Code:
    1. If text1.Text = "tainteddark1989" Then
    2. SaveSetting "APPNAME", "DATA", "RUNS", 0
    3. unock_all 'unlocks form
    4. End If
    5. End Sub

  14. #14
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,784

    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...

  15. #15
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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?

  16. #16

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    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

  17. #17
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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"

  18. #18

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    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

  19. #19
    Fanatic Member space_monkey's Avatar
    Join Date
    Apr 2005
    Location
    神と歩くこと
    Posts
    573

    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

  20. #20
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: tell how many times app is run

    What variable? What line?

  21. #21

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: tell how many times app is run

    on the line

    VB Code:
    1. DeleteSettings  "APPNAME", "DATA", "RUNS", [COLOR=Red]NumofRuns[/COLOR]
    NumofRuns gives me a varible not defined error and when i dim it

    VB Code:
    1. [COLOR=Magenta]dim NumofRuns as Integer[/COLOR]
    2. DeleteSettings  "APPNAME", "DATA", "RUNS", NumofRuns

    it says "invalid number of arguments"
    Last edited by dark_shadow; Sep 2nd, 2005 at 04:54 PM.

  22. #22
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: tell how many times app is run

    Just use this:
    VB Code:
    1. DeleteSettings  "APPNAME", "DATA", "RUNS"

  23. #23

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: tell how many times app is run

    it still dosent seem to work

    VB Code:
    1. Private Sub mnuunlock_Click()
    2. DeleteSettings  "APPNAME", "DATA", "RUNS"
    3. unock_all'unlocks the buttons on the form
    4. End Sub

    is this correct? i keep getting a varible not defined error for the DeleteSettings

  24. #24
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: tell how many times app is run

    Oops. KIM that this removes ALL settings from the key
    VB Code:
    1. DeleteSettings  "APPNAME", "DATA"

  25. #25

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: tell how many times app is run

    still no go i keep gettin the same error

    VB Code:
    1. Private Sub mnuunlock_Click()
    2. DeleteSettings  "APPNAME", "DATA",
    3. unock_all'unlocks the buttons on the form
    4. End Sub
    Last edited by dark_shadow; Sep 2nd, 2005 at 06:15 PM.

  26. #26
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    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"

  27. #27
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,784

    Re: tell how many times app is run

    Quote Originally Posted by dark_shadow
    still no go i keep gettin the same error

    VB Code:
    1. Private Sub mnuunlock_Click()
    2. DeleteSettings  "APPNAME", "DATA",
    3. unock_all'unlocks the buttons on the form
    4. End Sub
    How about removing the comma at the end of this line:
    VB Code:
    1. DeleteSettings  "APPNAME", "DATA"[b],[/b]

  28. #28

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    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

  29. #29
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  30. #30

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: tell how many times app is run

    alright i get it but how exactely would i check for it ?

  31. #31
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: tell how many times app is run

    This pseudo code of what you shoud do:

    VB Code:
    1. Dim Count As Integer
    2.  
    3.    Count = GetSettings ("APPNAME", "Count")
    4.    If Count < 40 Then
    5.        Count = Count + 1
    6.  
    7.        SetSettings "APPNAME", "Count", Count
    8.    Else
    9.       'Terminate application
    10.    End If

  32. #32
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: tell how many times app is run

    To unlock:

    VB Code:
    1. dim ff as integer
    2. open app.path & "\unlock.txt" for output as #ff
    3.   print #ff, "unlocked"
    4. close #ff

    To load:

    VB Code:
    1. If Dir(app.path & "\unlock.txt" ) = "" then ' Not found
    2.   ' read count into registry
    3.   if regcnt > 40 then
    4.     msgbox "Time trial is up!"
    5.     unload me
    6.   endif
    7. endif

  33. #33

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: tell how many times app is run

    VB Code:
    1. dim ff as integer
    2. open app.path & "\unlock.txt" for output as #ff
    3.   print #ff, "unlocked"
    4. close #ff

    on this code i'm getting a "bad file name or number error"

  34. #34
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: tell how many times app is run

    Oops. That's what I get for free-handing it.

    VB Code:
    1. dim ff as integer
    2. [COLOR=Red]ff = freefile[/COLOR]
    3. open app.path & "\unlock.txt" for output as #ff
    4.   print #ff, "unlocked"
    5. close #ff

  35. #35

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: tell how many times app is run

    alright so i'm suppost 2 put this

    VB Code:
    1. If Dir(app.path & "\unlock.txt" ) = "" then ' Not found
    2.   ' read count into registry
    3.   if regcnt > 40 then
    4.     msgbox "Time trial is up!"
    5.     unload me
    6.   endif
    7. endif
    in a differnt prog to check it?

  36. #36
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  37. #37

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: tell how many times app is run

    VB Code:
    1. If Dir(app.path & "\unlock.txt" ) = "" then ' Not found
    2.   ' read count into registry
    3.   if [COLOR=Red]regcnt[/COLOR] > 40 then
    4.     msgbox "Time trial is up!"
    5.     unload me
    6.   endif
    7. endif

    ok i keep getting a "varible not defined error"

  38. #38
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: tell how many times app is run

    Quote Originally Posted by dark_shadow
    VB Code:
    1. [COLOR=Blue]dim regcnt as long[/COLOR]
    2. If Dir(app.path & "\unlock.txt" ) = "" then ' Not found
    3.   ' read count into registry
    4. [COLOR=Blue]    regcnt = Val(GetSetting("APPNAME", "DATA", "RUNS", 0))[/COLOR]
    5.   if [COLOR=Red]regcnt[/COLOR] > 40 then
    6.     msgbox "Time trial is up!"
    7.     unload me
    8.   endif
    9. 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

  39. #39

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Talking 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:
    1. Private Sub mnuunlock_Click()
    2.  Dim NumOfRuns As Integer
    3. NumOfRuns = Val(GetSetting("APPNAME", "DATA", "RUNS", 0))
    4. ' minus 40 therefor setting the value at 0 again
    5. NumOfRuns = NumOfRuns - 40
    6. SaveSetting "APPNAME", "DATA", "RUNS", NumOfRuns
    7. End Sub

    so far its works
    thank you so much for the input it is greatly appricated

  40. #40
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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
  •  



Featured


Click Here to Expand Forum to Full Width