Dragon_Z
6th March 2005 18:39 UTC
Serials and txt files
Hey, first of all I love the program and that is why I wanted to ask something.
I have a list of about 9999 serials in xxxx-xxxxxx-xxxx form and I would like to be able to make a page where a user can enter in a serial and a Username and if the serial is a good one and is in the .txt that is some where in the installer or in the actual code, it will save the username and serial to the registry in HKLM/Software/Digital Matrix/registration and continue with the installation, if it is a bad one and does not match a key in the .txt, I want it to say something like "you have entered a serial that is not valid" and when the click ok it will dump them back into windows.
Thx, if you need any more info just ask
Shea
6th March 2005 23:03 UTC
That would not be a very secure way of registering your product.
Dragon_Z
6th March 2005 23:34 UTC
it is pre regestration, the encryption algos and everything comes in after the program is first run and needs to be activated
Dragon_Z
6th March 2005 23:37 UTC
either way that is how the developer wants it and I want to do it this way and have the database of serials inside of the installer since otherwise I don't get payed
Jnuw
7th March 2005 02:46 UTC
Well as long as you have each serial on its own line within your txt file (with no white space before or after the serial), you could use the below function written by Afrow UK. Just make a loop and keep incramenting the line nuumber till you get a match...something like this should do (I have not tested this but it should give you the idea):
StrCpy $5 xxx ;set this var to user's entered serial
StrCpy $6 0
Loop:
IntOp $6 $6 + 1
StrCmp $6 10000 Invalid ;1 more than the # serials in file
Push $6 ;line number to read from
Push "$INSTDIR\file.txt" ;text file to read
Call ReadFileLine
Pop $0 ;output string (read from file.txt)
StrCmp $0 $5 End
Goto Loop
Invalid:
Abort "Your serial is invalid"
End:
MessageBox MB_OK "Your serial is good"
Function ReadFileLine
Exch $0 ;file
Exch
Exch $1 ;line number
Push $2
Push $3
FileOpen $2 $0 r
StrCpy $3 0
Loop:
IntOp $3 $3 + 1
ClearErrors
FileRead $2 $0
IfErrors +2
StrCmp $3 $1 0 loop
FileClose $2
Pop $3
Pop $2
Pop $1
Exch $0
FunctionEnd
Dragon_Z
7th March 2005 03:21 UTC
what section should everything go in?
Dragon_Z
7th March 2005 03:36 UTC
simply taking one of the basic example scripts and plugging the code in where it is supposed to go will work very nicely
Dragon_Z
8th March 2005 19:42 UTC
we decieded to not have a cheack inside the installer, what i need now is to be able to take the username and serial that a person enters on install and save it to the registry with the time of install, from there the developer will do the activation, how do I make these kind of fields?