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.
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)
Re: software limiting use
Quote:
Originally Posted by
SamOscarBrown
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.
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+
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.
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.
Re: software limiting use
thanks allot doogle let me try il get back to u all thens bro
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.
Re: software limiting use
Quote:
Originally Posted by
Doogle
@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
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.
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.......