Archive: RegCode


RegCode
Hi,

I can remember that somebody wanted to ask for regcode before installing... Well I created a little program that does it... Maybe someone else also created something like this, please post it as a reply to this thread, to compare codes and to choose the most efficient one...

You should first compile 'lis.nsi' as a seperate setup and use this one in the 'setup.nsi', take a look at the code available in Zip...

This 'lis.exe' is a seperate setup that calls InstallOptions with 'lis.ini'.

But I have one problem:
Does anyone know how to setup a one-to-one function to generate RegCodes and the inverse to check them, using MakeNSIS function and operators...
Or can anyone give me at least a hint???


Thx a lot, greetz, Hendri.


I don't know how to setup this algorithm with NSIS commands, but you could go the easier way and write a small extension-dll which computes like crazy.

~ Florian


Thx for your response Florian,
the problem is, I program in Matlab most of the times (it's a mathematical tool) and a little bit in Delphi. So I indeed tried to contruct some procedure in Delphi, but it already took 272K before I had even started programming... And my install data is just 200K, so this was no option :(
But I will try to get Delphi produce a smaller program...

If anyone has other ideas about how to do this, please post as a reply.

Greetz, Hendri.


Try making a command-line application out of your regcode-generator.
Now, before you start: you should make a regcode-VERIFIER, and not a generator. You can use the built-in Delphi function for command-line arguments (can't remember the name right now...) and then check it. Use ExitCode() to return an exit code which you can check in NSIS.
If you only use the sysutils package (you can remove the Classes in the uses clause unless you need it), your exe will be about 45-50 KB. After compression with UPX or just NSIS, it'll be a lot smaller.

This verification method isn't optimal, the best would be to make the application itself check the code... but I found even that isn't always good, so good luck :)


tried a little bit and :

does not work (w2k)

(error reading installer block)

using 1.9a

(my installer works)


Wrong thread? ;)


Koen thx for your advise about only using 'sysutils'. After creating a code generator, I now created a commandline checker of only ~41k (compressed ~22k) so i'm happy :D.

It would be better (because a Dos-screen pops up for a moment) if the Setup would be able to check the code itself, but well, no functions available in NSIS for this purpose...

The method of using a separate installer for the lisence screen and a separate checker now works but i think that this is not the most efficient routine... So if anyone has a suggestion about how to do this more efficiently, please reply...

Thx a lot all, greetz, Hendri.


If you remove the {$CONSOLE} define from your app, it will no longer be a command-line application, but a form-less application instead - no more popups.

There are ways to check codes with NSIS (it supports integers, strings and basic operations, so it can be done). It's just that I don't know what you need, some advanced things might not be possible.
It supports file operations too, so you can retrieve the code with InstallOptions and check it inside the installer itself.


Or, if you are interested, I just had the inclination to relive some of my Delphi days and ported ExDLL to delphi.
This is tested and compiled with Delphi 2.0 (ahh, the good ol' days) and I can safely say that after trying to do quite simple things, learnign C was the best decision I made :)

It is attached.


thx pjw62 and Koen, dank je!

But there's a little problem. So I now use your dll, pjw62, and I set $0 to the reg-code, import it in the dll, decode it and export the decoded name to the installer again and compare names there...

But my dll uses commands that might crash if the code is not quite ok... That's why I used a try-except clause. But in the dll this does not seem to work, because my installer crashes (due to the dll) if the code is incorrect...

Because you know a lot more about Delphi than me (as it seems) can you help me and suggest a solution?

Thx, Hendri.


Originally posted by F. Heidenreich
Wrong thread? ;)
all the time ...


just put the code from the dll here maybe then we will see whats wrong ...

I don't know which functions you are using, if you tell me on which functions you rely (besides basic arethmic functions), then perhaps we can convert it into an NSIS script?


well, i cannot reveal the secrets of my coding process but some of the information that's necessary to decode a possibly well-defined regcode is coded into this code. And I have to retrieve it in a certain way...

So for this task i use for example just the entries of a string. The problem is, if a code is not well-defined (in the way the dll expects it to be) than this string might not be of sufficient length and the dll crashes. I already tried to check this with an if-clause but this also didn't work strangely enough (debug: the string is empty and yet it's length was 2???).

But there are a lot of other different procedures than can crash in this case. So the best thing (i think) is to use something like tr-except if we can get this working again.

Question, it is actually possible to use try-except in a dll. I mean, does it do anything than???

If you have some suggestions, I would be really happy! THX!!!


try just using the winbloze api functions, like lstrlen etc.

But I would expect try-except to work in a dll, no reason why it shouldn't..

"Because you know a lot more about Delphi than me (as it seems) can you help me and suggest a solution?"

-- note, if you were talking to me, I am not an expert delphi programmer, perhaps some might say I used to be, but that was straight after I learned QBASIC a fair few years back.


thx pjw62, i'll try...
or otherwise create an exe...

but the thing about try:
i debugged the dll and at the point where the empty string was accessed, the debugging just stopped (access violation...) and there was no possibility to continue at except.

but it worked in the exe version... strange isn't it?
BTW i use Delphi 4...

Thx anyway for your advise, i'll try to figure something out with winbloze api functions.

Greetz, Hendri.


well, the new feature of .onNextPage makes it possible to ask for a RegCode just after the showing the lisence. So my complicated solutions with separate installer is not necessary anymore...

(see NSIS 1.9b2)

Greetz, Hendri.


Smile2Me,

Nice little thing you built there. Question though. How can I take the contents of Name and Registration Code and put it into the registry? I can do it with the WriteRegSt command but how can I pass that to the registry?

Thanks,
Derek


ssurfer26,

to ask for a RegCode, i would advise you to construct an INI now to load as an .onNextPage event. My solution posted in this thread works, but is outdated since .onNextPage is possible. After loadin the INI wait for the process to return and extract the RegName and RegCode from the INI using ReadINIStr. Pass this on the the registry (so you can use this info in processes later on in the installer) using WriteRegStr.

Is this an answer to your question?

Greetz, Hendri.


RegCode example
Hi all,

there seems to be more interest in RegCode than expected, so I created a little extract from my installer just to show you my way of asking the user for a RegCode.

Please remember that this is just one way of doing this, certainly not the most efficient one, but it works for me! Furthermore, please notice that there is a program on the internet to extract files from an NSIS installer, so your files might not be save using this solution. Maybe the files should then be encrypted first before crating the installer. Or maybe somebody has another idea...

Well, here are the files, good luck, if you have questions about this piece of the script, just post them here, it might be usefull for other people.

Greetz, Hendri.


I can't imagine...

Is everyone happy with my solution???
No objections or other solutions???

Just post it,

greetz, Hendri.