Would you want to zip up and send me your source code?
Printable View
Would you want to zip up and send me your source code?
evexa, I looked at your code and the project Startup Object should be Sub Main and not Form1. The way it works is that Sub Main calls the routine that finds out if the user is registered. If the user is registered then Sub Main displays Form1 otherwise it displays frmRegister.
(My 9000th post!)
Marty your suggestion worked perfectly thank you so much!
There is however one thing *:)*
The function includes a square root, a hard drive i tested had a negative number and obviously will not work with the sqrt.
I tried adding aline to say :
if strlicenceetc < 0 then strelicenceetc = (int(strelicenceetc * -1))
but it didnt work.
Any idea what i should do?
THank you :) :wave: :D
A couple of suggestions.
You don't have to use the alogrythm that I use at all so you can make one up that doesn't use the square root, or you can use the Absolute Value function (I thinks it's Abs but I can't check it now) before taking the square root. Whatever you do however make sure that you make the algorythm the same in both places.
Cheers Marty everything works perfectly now (well except for a registration error that occurrs but i think thats due to software on my machine that blocks silent emails.)
Thanks again!
xxx
Quote:
Originally posted by MartinLiss
A couple of suggestions.
You don't have to use the alogrythm that I use at all so you can make one up that doesn't use the square root, or you can use the Absolute Value function (I thinks it's Abs but I can't check it now) before taking the square root. Whatever you do however make sure that you make the algorythm the same in both places.
Yep, it is ;)Quote:
Originally posted by MartinLiss
(I thinks it's Abs but I can't check it now)
Excellent work Martin.
Just one suggestion to the people using this - You really do need to change the algorithm otherwise anybody can download the files above and generate keys for your program.
Thanks, but it's not up to change it. That should be done by whomever downloads it and I implied that in my original post. I did however edit that post to reinforce that point.
Hello Marty
I have a question that is VB 101 I'm sure but I can't find a reference to this type of usage, the so here we go:
In your code you append a $ to the end of some variables. I know that the $ is code for string variable. But you have already declared the variable as a string at the start of the function. So what is the purpose of the $ at this point?
Thanks
David
It's redundant. Some of the code I used was picked up from other places and I never bothered to change it.
Hello Marty
I have the program setup and working.
But my users get wigged out and shut it down when the program resolves the recipname and then again when it sends the email.
Either Outlook (depending on their security settings) or their anti-virus program will pop up a dire message on attempting to resolve the address that a virus may be attempting to access your address book and do you want to stop it?
Then it happens again when it goes to send the message and you get a simularly frightening warning. I tried remming out the resolvename line To at least get rid of the most dire of the two messages, but now it won't send the message and throws the dreaded error 32002 unspecified error.
Any ideas?
Thanks
David
Perhaps you could remove the automatic email and instead pop up a message saying something like "In order to register, please cut and paste the following information and send it in an email to..."
Is there a way to mail something without going thru Outlook?
Mapi appears to just be a portal to the installed email client. So, it looks like I will have to use something else to bypass Outlook. Any ideas?
Also what is the purpose of "resolving" the email address in outlook? I'm confused as to why when I supply it with an email addy thru the code it still needs to look it up in the outlook addy book.
If I could get it to send with out the name resolve it might be doable. As most people will ignore one mild warning if they trust the app. But almost no one will bypass the 3 dire "THIS MAY BE A VIRUS" warnings that mapi triggers in outlook.
Thanks
David
I did a forum search for email without outlook and this was one of the hits.
I also found this:
http://www.freevbcode.com/ShowCode.Asp?ID=109
I've given it a short test run and so far it seems to work very well. I'm going to send it to beta testers to see if it holds up under stress.
David
What if the user gets a new hard disk .....
he will have to register again ?
I use the same system with my program ..... and this is one of the problems I had to encounter .........
I save my registration info on a file .... is it better to store it on the registry ....... ?
Yes, the user will need to register again if he gets a new hard disk. I obviously think it's better to store the info in the Registry but some people like using files.Quote:
Originally posted by Dasiths
What if the user gets a new hard disk .....
he will have to register again ?
I use the same system with my program ..... and this is one of the problems I had to encounter .........
I save my registration info on a file .... is it better to store it on the registry ....... ?
could possibly be the reason the hard drive is showing as 0 is that the disks have been made as 'dynamic' under xp operating system?
Hi.....For the above code, may I know whether it is possible to modify it for my appforge program. My appforge program requires the user to register the name and product ID which is given by us and after the user register the name, he or she will be unable to change the name. My program is a chat program between a PDA and a desktop computer, so whenever the user message the computer using the PDA, the user name will be displayed. Assistance is much needed! Thank you for all the help! :)
I can't help you with that but you are welcome to copy and modify my code in any way you wish.
As someone already stated, it's probably not a good idea to base your registration scheme off of hardware. Instead I would look for information that is likely to be unique for a user but will survive some computer upgrades. Take a hash value of this information and then use it to generate the key.
Like what? What else is as unique as hardware? Something that just wouldn't possibly be the same for two different computers? :ehh:Quote:
Originally posted by Maven
As someone already stated, it's probably not a good idea to base your registration scheme off of hardware. Instead I would look for information that is likely to be unique for a user but will survive some computer upgrades. Take a hash value of this information and then use it to generate the key.
You would take a mixture of things from the computer. The windows CD key would be a good place to start. Any personal information should also be added.Quote:
Originally posted by manavo11
Like what? What else is as unique as hardware? Something that just wouldn't possibly be the same for two different computers? :ehh:
Hello somebody can of yours help oneself? I descended his code but this does not work for me, when running the protec.vbp error hits on this code to me:
Public Function GetSerialNumber() As Long
Dim strVolumeBuffer As String
Dim strSysName As String
Dim lngSerialNumber As Long
Dim lngSysFlags As Long
Dim lngComponentLen As Long
Dim lngResult As Long
StrVolumeBuffer$ String$ ( 256, 0 )
StrSysName$ String$ ( 256, 0 )
LngResult GetVolumeInformation ( C:, strVolumeBuffer$, 255, lngSerialNumber,
LngComponentLen, lngSysFlags, strSysName$, 255 )
GetSerialNumber lngSerialNumber
End Function
error is in this code, where he marks string$ to me:
StrVolumeBuffer$ String$ ( 256, 0 )
And the error that slips out is :
Error of compilation:
can not find the project or the library
Some of you can of yours help to me?
I say hello from mexico and thanks
I Right now did the trick, only me toward lack the reference to the library outl85.olb that is of outlook98, thanks anyway.
My code is meant for VB and not VBA.Quote:
Originally Posted by mykkel
Quote:
Originally Posted by mykkel
Hi, I am new here. I have downloaded your code. I am too having a problem.
I am running Win XP Home and I was able to compile the program where you can generate the key. But when I go to compile the protect.vbs it tells me the following:
Compile Error:
Can't find project or library
It references:
String$ in the line of strVolumeBuffer$ = String$(256, 0)
for
Public Function GetSerialNumber() As Long
Dim strVolumeBuffer As String
Dim strSysName As String
Dim lngSerialNumber As Long
Dim lngSysFlags As Long
Dim lngComponentLen As Long
Dim lngResult As Long
strVolumeBuffer$ = String$(256, 0)
strSysName$ = String$(256, 0)
lngResult = GetVolumeInformation("C:\", strVolumeBuffer$, 255, lngSerialNumber, _
lngComponentLen, lngSysFlags, strSysName$, 255)
GetSerialNumber = lngSerialNumber
End Function
in the modProtect.
Please advise.
Thanks
My code is meant for VB and not VBA. Are you using VB6?
I am using VB6 Enterprise EditionQuote:
Originally Posted by MartinLiss
What is the difference between VB and VBA?
VBA is Visual Basic for Applications and is the form of visual basic that you use from within Word, Excel etc.
What did you mean when you said "compile the protect.vbs"?
when i would do F5 when the project is open, or when it would attempt to compile into an exe.Quote:
Originally Posted by MartinLiss
Hey Martin....
Can you tell me what I am doing wrong here... I open your project vb file and I press the play button (F5)..
And I get a compile error - can't find project or library...
I am using Win XP and VB 6.0
The underlined line of code is highlighted blue when I get the error..
Thank you for taking the time!VB Code:
Public Function GetSerialNumber() As Long Dim strVolumeBuffer As String Dim strSysName As String Dim lngSerialNumber As Long Dim lngSysFlags As Long Dim lngComponentLen As Long Dim lngResult As Long strVolumeBuffer$ = [U]String$[/U](256, 0) strSysName$ = String$(256, 0) lngResult = GetVolumeInformation("C:\", strVolumeBuffer$, 255, lngSerialNumber, _ lngComponentLen, lngSysFlags, strSysName$, 255) GetSerialNumber = lngSerialNumber End Function
Stilekid007 :wave:
There may be something in your project that's confusing VB. Try
VB Code:
strVolumeBuffer$ = [HL="#FFFF80"]VBA.[/HL]String$(256, 0)
Thank you so much marty!
Thats worked! Thats a really nice program... :thumb:
So I understand if the user doesn't have outlook then it will display a message window saying send an email to blah blah blah...
Is this a correct asumption?
Thanks again man! :wave:
Yes, that's the assumption. There are other, more general, ways of sending email and so if you have the need you might want to look into changing the code.
Hi,
I have tried using this register programming. If i just run, i am getting compile error as "Cannot Find Project or Library". Can anyone suggest me, whether i shd include any library as reference??? Expecting ur reply,
Thanks in advance,
Regards,
dpr
HELLO,
Thanks a lot for the above suggestions. I read the previous thread and included VBA. The program is working fine.. Thanks a lot.
Regards,
dpr
What would I have to remove and fix, if I wanted it so it skipped the automatic outlook email, and just popped up the manual email form where it says an error has occured, please use your email system to manually send and email to....
Could someone tell me what I need to do?
PS: Im very very new to VB and have no idea what to do on my own.
-Sidewinder
You are much better off creating an installation package so the user will be able to use MAPI but here you go.
VB Code:
Public Sub ShowStep1() cmdNext.Caption = "&Next >" cmdBack.Enabled = True lblReg.Caption = "Step 1 - Request Registration Key" [HL="#FFFF80"]' lblExplain.Caption = "Pressing Next will generate an " _ ' & "E-mail requesting a Registration Key. When you receive " _ ' & "that key via return E-mail, you can finish the " _ ' & "registration process by completing the " & optRegStep(1).Caption _ ' & " step, (Step 2)." lblExplain.Caption = "Press Next and then send me an " _ & "E-mail as you will be instructed to. When you receive " _ & "that key via return E-mail, you can finish the " _ & "registration process by completing the " & optRegStep[/HL](1).Caption _ & " step, (Step 2)." optRegStep(0).Visible = False optRegStep(1).Visible = False lblName.Visible = True txtName.Visible = True [HL="#FFFF80"] 'new txtName.Text = "Press Next" txtName.Enabled = False[/HL] lblRegKey.Visible = False lblRegisterTo.Visible = False txtRegisterTo.Visible = False txtRegKey(0).Visible = False txtRegKey(1).Visible = False txtRegKey(2).Visible = False lblDash1.Visible = False lblDash2.Visible = False [HL="#FFFF80"]' txtName.SetFocus[/HL] End Sub Public Function RequestKey() As Boolean ' Dim strCriteria As String Dim mpSession As MAPISession Dim mpMessages As MAPIMessages On Error GoTo ErrorRoutine ' This causes this validation (for step 1) to ' be bypassed when going directly to step 2 If txtName.Visible = False Then RequestKey = True Exit Function End If If Trim(txtName) = "" Then MsgBox "Please enter your name.", _ vbExclamation, REG_ERR_TITLE txtName.SetFocus m_StepCompleted = m_StepCompleted - 1 Exit Function End If Screen.MousePointer = vbHourglass Me.Hide [HL="#FFFF80"]' frmWait.Show ' ' gRegClass.Subject = StrConv(LCase(App.EXEName), vbProperCase) & " Registration Request" ' ' Set mpSession = MAPISession1 ' Set mpMessages = MAPIMessages1 ' ' mpSession.DownLoadMail = False ' 'show the logon interface for the mail ' mpSession.LogonUI = True ' 'sign on to selected account ' mpSession.SignOn ' ' DoEvents ' ' 'check if logon was successful ' If mpSession.SessionID = 0 Then ' 'SendMAPIMail = False ' MsgBox "Error On login To MAPI", _ ' vbCritical, "MAPI" ' Exit Function ' End If ' ' 'set the session IDs the same on both objects ' mpMessages.SessionID = mpSession.SessionID ' ' 'Set the MSgIndex to -1, this needs to be ' 'done for the Compose event to work ' mpMessages.MsgIndex = -1 ' 'compose a new message ' mpMessages.Compose ' ' 'don't show the resolve address interface ' mpMessages.AddressResolveUI = False ' ' 'set the recipient ' mpMessages.RecipIndex = 0 ' mpMessages.RecipType = mapToList ' mpMessages.RecipAddress = EMAIL ' 'resolve the recipient's email addresses ' mpMessages.ResolveName ' ' 'set the subject ' mpMessages.MsgSubject = gRegClass.Subject ' ' 'set the Message/Body/NoteText ' mpMessages.MsgNoteText = txtName & " " & GetSerialNumber ' ' 'send the message ' mpMessages.Send ' ' 'close the current session ' mpSession.SignOff ' ' 'clear objects ' Set mpMessages = Nothing ' Set mpSession = Nothing 'new MsgBox "Send me an email which includes your name and this number." _ & vbCrLf & vbCrLf & GetSerialNumber[/HL] Screen.MousePointer = vbNormal Unload Me DoEvents RequestKey = True Unload frmWait Exit Function ErrorRoutine: Set mpMessages = Nothing Set mpSession = Nothing Screen.MousePointer = vbNormal frmRegError.Show vbModal m_StepCompleted = m_StepCompleted - 1 RequestKey = False Err.Clear End Function
I`m using your code as a foundation to my own registration scheme. It`s been very instructive and helpful. One thing I`d like to ask is why do you tell that the main form of my program has to be loaded in modal mode. My main form is an MDI container form and it crashes when I try to load it in modal mode.
Because in the code below if frmDone wasn't shown modally, the code would continue through the unloading of all forms and the immediate ending of the program.
VB Code:
Public Sub Main() Dim frm As Form ' Create a Form object GetAppEnvironment ' Calls the routine that finds out if the user is registered If Not gRegClass.Registered Then ' Registered is a boolean property of theCRegister class frmRegister.Show vbModal ' If the user is not registered then the register form is displayed Else frmDone.Show vbModal ' In this app if the user is registered then frmDone is displayed. ' In your app you would probably replace frmDone with your main form End If For Each frm In Forms ' Loop through all the forms... Unload frm ' and unload them... Set frm = Nothing ' and set them to Nothing Next End ' 99.99999% of the time not needed, but it can't hurt after you've unloaded your forms. End Sub
I`m not doing it exactly that way. I load my main MDI form in non-modal mode. Then , I just unload the form showing the splash screen. All, others forms are unloaded when the main MDI form is closed. So, effectively the program does not terminate. Is there any defect to this method?
None that I can see.
first of all, thank you martin for providing such a useful and practical piece of code. this is definitely a good start for anyone out there wishing to implement a registration routine.
however, i am actually a 'protection freak', and believe that some members might not realize that despite being an excellent start, this scheme is very easy to crack.
therefore, though being as i stated an excellent starting point, i would recommend all users of this piece of code to consider implementing some of these suggestions to ensure an increased protection of their software.
i had provided an example of what could be attacked in the scheme, however as you can see in the post here below it has been removed by martin.
unfortunately, it is hard to explain how to protect a software without having a basic understanding of what you are trying to protect from, however i guess martin is right, this might have given bad ideas to some uneperienced vb'ers.
i remain however at disposal to discuss 'concepts' (i won't then distribute code) to honest programmers trying to protect their software.
cheers,
wc.
I removed the attachment since code like that should not be distributed on this forum even if you have the best of intentions.
My program is not meant to be foolproof (if there is actually such a thing) but only a "locked door" to keep out the casual hacker.
No way of protection is certainly foolproof. While there are fairly simple easy ways to break the scheme proposed my Martin, it is only a matter of time and resources to break more complicated schemes.
It remains a matter of how broad an audience your application is targeted. Not many people will go into lengths to crack an application that is only being used by a few people.
this is particularly true. however, it is not my intention here to enter another lengthy discussion on the fact that there are no unbreakable protections. we all know that.Quote:
Originally Posted by divined
my point was that you can seriously 'buy time' before your program protection is broken, and that this scheme, though being as i stated an excellent start, is only useful 'as is' exactly if the audience you are targeting as no interest in doing so (for instance in professional and specific applications).
Hi
I am facing a silly problem. I downloaded your code as it is and trying to comple it. When I am compiling it, it is giving me an error ie, " Compile Error : Can't find project or library." and closing it. it is getting stuck in this section :
Public Function GetSerialNumber() As Long
Dim strVolumeBuffer As String
Dim strSysName As String
Dim lngSerialNumber As Long
Dim lngSysFlags As Long
Dim lngComponentLen As Long
Dim lngResult As Long
strVolumeBuffer$ = String$(256, 0)
strSysName$ = String$(256, 0)
lngResult = GetVolumeInformation("C:\", strVolumeBuffer$, 255, lngSerialNumber, _
lngComponentLen, lngSysFlags, strSysName$, 255)
GetSerialNumber = lngSerialNumber
End Function
highlighting String$ in the code. Also I tried to find the defination of String$ by right clicking but the result is "Identifier under cursor is not recognized." Can you tell me how to solve this problem and compile your code.
:confused:
String$ is a member of VBA's Strings class just as are Trim, strConv, Right$, etc. Highlight String$ and press Shift-F2 to open up the Object Browser. Does it find it String$? The only things I can suggest is that you try using String instead of String$ or perhaps VBA.String$. BTW when you type VBA.S does Intellisense show you String$ as one of the possible choices?
can someone pm me the exe files?, b/c my vb is corupt
i doubt anyone is going to do it and if its a corrupt installation then youre going to have to reinstal VB.Quote:
Originally Posted by r6k.net
Im not sure if this post is still alive but i doo see a post from a few days ago. But i tihnk i have a simple error. When i try to get my serial number from the program i get a negative number (-2072485274) and of course the program does not like that.
I tried change a line of the generaation a someone posted way back, but still that did not help...Any Ideas?
Just work with the absolute value (using the Abs function).Quote:
Originally Posted by eddied316
I did try that.
I changed:
VB Code:
strLicenseKey = CStr(Int(3456 * Sqr(lngSerialNum / 5)))
To
VB Code:
strLicenseKey = CStr(Int(3456 * Sqr(Abs(lngSerialNum) / 5)))
On both PRojects but my number still turns out t be:
(-2072485274)
Do
strLicenseKey = CStr(Int(3456 * Sqr(Abs(lngSerialNum) / 5)))
I got your PM. If you use the formula I posted in post #115 in both places you will get a value of 70361397.
lol...i DID use it in both places
but it doesnt change
I used it in the Main program in the Moduels and the second on on the gen
but stil get the -207...
Hi guys,
I have read with interest the discusion on the above program. However, I was thinking aloud, suppose my client does NOT have an e-mail address or his machine is not connected to the internet, then how can he be able to install this sofware on his machine|? How do you generate the serial number manually?
Thanks.
When the person who doesn't have email installs the program, a value that represents the hard drive serial number will be displayed. Have them phone or snail-mail the value to you. You then run GenKey (as you would normally) and call or snail-mail them back their key.Quote:
Originally Posted by osemollie
Sorry, I am trying out the program but I don't see a value that represents the hard drive serial number displayed. How do I get it displayed?
Thanks