View Full Version : external DLL
4th June 2003, 10:10
OK. this is a little hard to explain.
i have a custom page with 2 textbox. (from an .ini file)
1. the user enters a code in every one of them.
2. when next button is pressed:
3. the content of the both textbox is stored in variables or constants (?)
4. i must use this variables/constants to validate the codes. something like this, with a function:
function ValidateSerialNumber(myFile, User, Orgn, , , , PrivateKey, Serial: String): Boolean;
and then to call the DLL. i found in documentation that is something like this:
System::Call 'YourDllName::YourDllFunction(i, *i, t) i(.r0, r1, .r2) .r3'
5. if the codes are not correct the user is not allowed to move on.
if you have any ideas how to do this, tell me, please,
becuase i have no idea.:igor:
4th June 2003, 11:48
You can use the System plug-in to call your DLL, but maybe it's easier to create a NSIS plug-in.
4th June 2003, 12:05
sorry! you lost me...i am reding the system readme, but noy understanding a thing.
let's do this step by step:
how do i take the content of the both textbox and store them in variables or constants (?)
4th June 2003, 13:01
Note that you must implement a dll ( for this example is "MyExternDLL.dll" with export "ValidateUser") and store the dll in NSISDIR\Plugins
Just use some source code from other plugin (NSISDIR\Contrib) so that you can start and change the code
You can debug easily if using VC++, just change project settings and choose your output setup.exe as "Executable for debug session"
4th June 2003, 19:20
A better way would be checking the leave function. See the example in Contrib\InstallOptions\test.nsi. It does exactly this.
As for the DLL, you didn't write it right? Do you have the source code for it? If you don't then you'll need to call it using System. Show me the function prototype and I'll help you writing a System::Call line. If you do, then you might want to consider compiling a NSIS plug-in version so it'll be easier to call.
5th June 2003, 07:22
thanks, again, for helping,
ok. i checked the "Contrib\InstallOptions\test.nsi" script. i have now the codes entered by the user in 2 variables (from the textboxes).
as for the DLL, i did not write it, i do not have the source code.
i don't know what you mean by "function prototype". if you are talking about what i made so far, no problem. but until now i have only a custom page with 2 textbox. (btw: one textbox, two textboxes ?, my english is not so good)
"function ValidateSerialNumber(myFile, User, Orgn, , , , PrivateKey, Serial: String): Boolean;", this is taken from the DLL readme.
myFile - is encrypted file (i have it) - OK.
user and orgn - user name, organization name (automatic inside the installer). - OK.
PrivateKey and Serial - the 2 textboxes. - OK.
all i have to do now is to call the DLL with all this parameters. the DLL returns true or false. if its false, the user will not be allowed to pass.
to compile a NSIS plugin version? no problem. if it works...
5th June 2003, 13:38
"function ValidateSerialNumber(myFile, User, Orgn, , , , PrivateKey, Serial: String): Boolean;" is the function prototype, but it doesn't make sense to me. Is another line that looks like that in the readme? Something with char* or LPSTR? Will you be able to attach the readme or mail it to me privately?
If you haven't written the DLL and you don't have the source you can't compile it as a NSIS plug-in.
5th June 2003, 14:41
after a few hours spent in "The Archive" and readme files, it's a little better. i can say i'm begining to understand what you're talking about.
yes, there were some stuff there. i will attach it.
5th June 2003, 15:28
According to this program's readme (download from http://www.mjfreelancing.com/) the call should be:
System::Call "ISID::ValidateSerialNumber(t, t, t, t, t, t, t, t) i ('keypath', 'user', 'orgn', '', '', '', 'user private key', 'user serial') .s"
$0 contains the result.
Make sure the DLL is somewhere System.dll can find it (the current directory set by SetOutPath for example). The best way would probably be extracting the DLL to $PLUGINSDIR and using SetOutPath $PLUGINSDIR.
6th June 2003, 05:50
i tried to make it work, but no. sorry
i will attach my script, but i cannot attach the DLL, is about 1.3MB. download it from - see above.
my condition after the DLL sytem call is not good, if you do not enter the right codes you cannot exit the program. even if you press back or cancel.
and even in the System::call line i did something wrong. the DLL always returns "0" or "false" - if i change from "i" (int) to b(boolean). and the codes are good. i checked. too make it easy i enetered the codes in the ini file.
here is the script.
6th June 2003, 10:46
The wrong thing in the DLL function call is just the order of the last two arguments. Unlock code should come after the private key.
For the user to be able to exit the installer you must use the leave function of the page. The leave function is only called when the user clicks next. If the DLL returns false you should call Abort to not allow the user to continue to the next page.
Leave callback funciton is not available in b3 but only in the latest CVS version. Use NSIS Update to get it. If you don't want the latest CVS version you should use something like the code in this page:
You will also notice the $PLUGINSDIR is not deleted. This seems to be a feature of Systemd.dll I have never noticed. It doesn't free DLLs. To make sure the DLL is deleted you can use this trick:
RegDLL $PLUGINSDIR\ISID.dll "a function name that doesn't exist"
This will make NSIS load the DLL and then unload it completely.
6th June 2003, 13:09
sorry. my mistake.
i inverted the last 2 arguments (.r3, .r4 is now .r4, .r3) and still the DLL response is "0" or "false".
i don't get it.
6th June 2003, 14:11
i changed my script to use the leave function. (i think)
but now i get this :
install function ... not referenced - zeroing code ...
how do i use "abort" ?
is this correct ? : StrCmp $0 "false" Abort.
i'll answer that. no. then how ?
6th June 2003, 17:21
You should be using:
Page custom "Protect" "Validate" "Title"
Where "Title" is the title of the custom page (e.g. " - Enter Codes")
7th June 2003, 09:32
Remove the dots and it should work:
System::Call "ISID::ValidateSerialNumber(t, t, t, t, t, t, t, t) i ('$PLUGINSDIR\OwD.iky', r1, r2, '', '', '', r4, r3) .s"
10th June 2003, 09:23
thanks for helping. here is the working script. feel free to use it.
18th June 2003, 22:30
That looks pretty good.
Can anyone think of any way of exposing that DLL to IIS / ASP environment so that the customer can be emailed their registration code automatically after purchasing the download online? (based on the details they enter)
25th June 2003, 11:24
If everything else fails you can always write a little NSIS script that will call the DLL, and write the result into a file which the ASP code will read. Use a silent "installer" to do the job.
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.