Results 1 to 12 of 12

Thread: software limiting use

  1. #1

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Exclamation software limiting use

    need help limiting the use of software by using a counter or other ways u may know

    i want to limit my software from being used after limit is reached then prompt

    i have a label1.caption= 0 this counter goes up by 1,2,3 etc on when it reaches 30 then then write a hidden file or to a registry and disallow user to reopen the .exe file
    and prompt user you have to purchase this software you have used all your limits please help
    Last edited by ladoo; May 24th, 2013 at 07:55 AM.

  2. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: software limiting use

    You can save the counter in a file or registry value, usually when the program starts for first time, the file or reg value is not exist, so create it and write the counter, then continue increase it until it reach 30, prompt the user to purchase the software.

    To limit by period of time, e.g. 30 days, when the program starts for first time, save the system date in a file or reg value then in each run calculate the date difference between the saved date and the Now function.
    Last edited by 4x2y; May 24th, 2013 at 10:06 AM.



  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: software limiting use

    You could simply unload the form (program) during your main form load routine after you check the value of your label. No need for hidden files/registry entry. Just do this:

    Code:
    Private Sub Form_Load()
    If Label1.Caption = "30" Then
    MsgBox "You have exceeded the number of times to run this program."
    Unload Me
    End If
    End Sub
    EDIT: HOWEVER, the post by 4X will work just fine....especially if you wanted to do the "30 day" thingy. (Just saw that post)

  4. #4
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: software limiting use

    Quote Originally Posted by SamOscarBrown View Post
    No need for hidden files/registry entry.
    This is OK if we are talking about single session, but what if the user turn off the computer? therefore the counter must be saved somewhere in a file or the registry.



  5. #5

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: software limiting use

    guys please help just small help to store the value 30 and check it on form load

    @max sir i no this but the main this is hiding the value and chking it up on form load, il manage the encryption just need to store it , if it was you were will u store it.?
    Private Sub Form_Load()
    If Label1.Caption = "30" Then
    MsgBox "You have exceeded the number of times to run this program."
    Unload Me
    End If
    End Sub

    i need to store the 30 somewere encrypted so the user cant alter it ,, i dont need 30 days trial thing because this will be effective enough

    when user first starts the programme counter is 0 when he uses the software if it reaches 30 thats it usage is done , even he tries to reinstall it and open exe then show prompt to buy com on guys few examples will be nice and credits will be gives rep+++++++


    @4x2y an example of how to store in reg and read will be appreciate it and rep+

  6. #6
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: software limiting use

    Here is an example
    Code:
        Private Sub WriteCounterToRegistry()
    
            Try
                Const strValueName As String = "run counter"
                Const strValuePath As String = "Software\myapp-name"
                Dim cRegKey As RegistryKey
                cRegKey = Registry.CurrentUser.OpenSubKey(strValuePath, True)
    
                If cRegKey Is Nothing Then 'not exists, create it.
                    Registry.CurrentUser.CreateSubKey(strValuePath)
                    cRegKey = Registry.CurrentUser.OpenSubKey(strValuePath, True) ' open it again and set to 1
                    cRegKey.SetValue(strValueName, 1, RegistryValueKind.DWord)
                Else 'exists, check it.
                    Dim intCounter As Integer = CInt(cRegKey.GetValue(strValueName, 0))
    
                    If intCounter >= 30 Then
                        MessageBox.Show("you must buy", My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Information)
                        ' show how to buy form then exit.
                    Else
                        ' start normal
                        intCounter += 1 ' increase and store.
                        cRegKey.SetValue(strValueName, intCounter, RegistryValueKind.DWord)
                        ' show main form.
                    End If
                End If
    
                cRegKey.Close()
    
            Catch ex As Exception
                ' handle any exception or just ignore it.
            End Try
    
        End Sub
    Of course the trick here is the path you will choose to store the counter, it shouldn't be so direct like that as it will easy to find and delete to reset the counter.
    Don't try write under Registry.ClassesRoot or Registry.LocalMachine as needs run your app as an admin.

    BTW: that method is easy to hack by any advanced user.
    Last edited by 4x2y; May 24th, 2013 at 03:25 PM.



  7. #7
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: software limiting use

    @4x2y: Nice code but it's for VB.Net, OP is using VB6.

    Something similar could be achieved using GetSettings and SaveSettings in VB6
    Code:
    Private Sub Form_Load()
    Dim strData As String
    Dim daStart As Date
    Dim intUsed As Integer
    strData = GetSetting(App.EXEName, "Trial", "DateStarted", vbNullString)
    If strData = vbNullString Then
        SaveSetting App.EXEName, "Trial", "DateStarted", Format(Now, "dd/mmm/yyyy")
        Load TheMainForm
        TheMainForm.Visible = True
    Else
        daStart = CDate(strData)
        intUsed = DateDiff("d", daStart, Now)
        If intUsed > 30 Then
            MsgBox "Your Trial Period has Expired - the Program will now Terminate"
        Else
            Load TheMainForm
            TheMainForm.Visible = True
        End If
    End If
    Unload Me
    End Sub
    This creates a Register entry in HKEY_CURRENT_USER\Software\<your program's exec name>\VB and VBA Program Settings\Trial\
    with a KeyName of "DateStarted" containing the date the Program was first executed.

    It's quite easy to 'hack' if the user knows what they're doing (by just deleting the Key once they've found it.) You could use the Registry APIs rather than GetSetting and SaveSetting, to establish a Key elsewhere but it all depends upon how much effort you want to put in to hide it. The determined 'hacker' will probably find and avoid it.

    @ladoo: I seem to remember discussing this topic at length in another of your Threads here.

  8. #8

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: software limiting use

    thanks allot doogle let me try il get back to u all thens bro

  9. #9
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: software limiting use

    Another alternative is that you limit the features of your software, perhaps disable some buttons, menu, etc. instead of giving a time-limit.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  10. #10
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: software limiting use

    Quote Originally Posted by Doogle View Post
    @4x2y: Nice code but it's for VB.Net, OP is using VB6.
    Oops

    Here is a VB6 class uses API functions to write anywhere inside the registry. http://www.vbaccelerator.com/home/VB...ol/article.asp



  11. #11
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: software limiting use

    I would use the file Date Created (no need to save anything). If Now > FileCreated + 30 Then "Please register software!"

    Of course my if wont work or you might use DateDiff or whatever works for you.
    The thing is, yes but a reinstall would restart a 30 day trial?
    Well then you also use a key in registry not registered under Trail, nor registered under the program name.
    You could fake it like it was Internet Explorer so people would avoid deleting it.
    Also you could create a file somewhere in pc for a third backup.

    Ad said before it all depends on how much you want to make it work.

  12. #12
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: software limiting use

    DUH!!!...Sorry....wasn't even thinking when I posted (#3).....
    Personally, I prefer the use of a value in a database (and that database can be password protected and/or the value encrypted). Upon program start, check the value, and if okay to run, increment it by one. As I use DB's in MOST of my apps, it is a simple way of keeping a value around, and 'hiding' it from the user as well.

    Again, sorry for post #3.....that was FRIDAY and I was eager to get off work.......

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width