Archive: Serials and txt files


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


That would not be a very secure way of registering your product.


it is pre regestration, the encryption algos and everything comes in after the program is first run and needs to be activated


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


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

what section should everything go in?


simply taking one of the basic example scripts and plugging the code in where it is supposed to go will work very nicely


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?