This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Serial number validation dll
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 18, 2007
10:21 AM
Serial number validation dll
Hi,
I want to create my own dll to validate the serial number entered in the CustomerInformation dialog. Where should I put the dll in the project (SUPPORTDIR?) and how do I call it through a custom action ?
I searched the website about this problem and I only found information related to InstallShield 2008 Express (here) and I did not found the field the authors refers to.
Thanks,
I want to create my own dll to validate the serial number entered in the CustomerInformation dialog. Where should I put the dll in the project (SUPPORTDIR?) and how do I call it through a custom action ?
I searched the website about this problem and I only found information related to InstallShield 2008 Express (here) and I did not found the field the authors refers to.
Thanks,
(17) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 18, 2007
01:52 PM
Since a DLL is really an assembly, then it may need to be placed in its own component (with nothing else in the component).
I think what you are saying would work. You would want to create an InstallScript custom action and first load the DLL, call the serial number validation function, then unload the DLL.
I think some people place a Validate button in the CustomerInformation dialog. When the user clicks the button, you have a DoAction behavior on the Validate button that calls the custom action. You would also attach a condition to the Next button that the user can't move forward until he has validated the serial number. You could do this by checking if a property has been set (your validate function would set the property if the validation has passed).
I think what you are saying would work. You would want to create an InstallScript custom action and first load the DLL, call the serial number validation function, then unload the DLL.
I think some people place a Validate button in the CustomerInformation dialog. When the user clicks the button, you have a DoAction behavior on the Validate button that calls the custom action. You would also attach a condition to the Next button that the user can't move forward until he has validated the serial number. You could do this by checking if a property has been set (your validate function would set the property if the validation has passed).
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 18, 2007
02:00 PM
Thanks, I've already implemented something to validate the serial number on the next button event. About the idea of putting the DLL in a component I'll try it, but how would I acces it at run-time ? The components are not copied to disk yet at this moment during the installation.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 18, 2007
02:37 PM
I don't understand your question.
If you put the DLL in a component, and attach no conditions to it (the component), and point the component destination to say [INSTALLDIR], then there is no reason why it wouldn't be copied to your target folder upon installation.
If you put the DLL in a component, and attach no conditions to it (the component), and point the component destination to say [INSTALLDIR], then there is no reason why it wouldn't be copied to your target folder upon installation.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 18, 2007
02:38 PM
The validation of the serial occurs before the files are copied to disk.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 18, 2007
03:26 PM
Pardon me, I made a mistake. What you said makes perfect sense.
So then, you are correct. You would need to place the DLL in the SupportFiles/Language Independent folder. That is where the files will be extracted to during the installation. Then in the custom action, you would build a path to the DLL using the SUPPORTDIR variable.
How about that?
So then, you are correct. You would need to place the DLL in the SupportFiles/Language Independent folder. That is where the files will be extracted to during the installation. Then in the custom action, you would build a path to the DLL using the SUPPORTDIR variable.
How about that?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 18, 2007
03:33 PM
Ok Good! I should install the files in the SUPPORTDIR. That was my first question.
Now, the second part of my question. How may I call the DLL via a Custom Action ? I can launch a CA at the right moment during install, but I can't make that CA to launch a dll stored in SUPPORTDIR.
Now, the second part of my question. How may I call the DLL via a Custom Action ? I can launch a CA at the right moment during install, but I can't make that CA to launch a dll stored in SUPPORTDIR.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 18, 2007
03:41 PM
First I would probably create an InstallScript function in the InstallScript view. Call it something like ValidateSerialNumber. At this point you could make it an empty function. Just a frame so you could create the custom action.
Then create an InstallScript custom action that uses the ValidateSerialNumber function.
If you placed a Validate button in the CustomerInformation dialog, then you would need to go to the Dialogs view, expand the CustomerInformation dialog, click Behaviors, then click on the Validate button. Then create a DoAction event with the argument ValidateSerialNumber and a Condition of 1. So, when the user clicks the Validate button, the custom action will be called.
Now, go back to the ValidateSerialNumber InstallScript function, call UseDll() to load the DLL, then call the validate function in your DLL, then call UnUseDLL() to unload the DLL, and pass the result back to the installer. Maybe create a property and set the property based on the result of the validate function, then don't let the user go forward (when hitting Next), until the property is set to the correct value.
Something like that.
Then create an InstallScript custom action that uses the ValidateSerialNumber function.
If you placed a Validate button in the CustomerInformation dialog, then you would need to go to the Dialogs view, expand the CustomerInformation dialog, click Behaviors, then click on the Validate button. Then create a DoAction event with the argument ValidateSerialNumber and a Condition of 1. So, when the user clicks the Validate button, the custom action will be called.
Now, go back to the ValidateSerialNumber InstallScript function, call UseDll() to load the DLL, then call the validate function in your DLL, then call UnUseDLL() to unload the DLL, and pass the result back to the installer. Maybe create a property and set the property based on the result of the validate function, then don't let the user go forward (when hitting Next), until the property is set to the correct value.
Something like that.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 18, 2007
03:44 PM
I've thought about this a lot because I had to do the same thing for my own project. This seemed like the best way to go.
Other people may have other ideas.
Other people may have other ideas.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 18, 2007
04:33 PM
Nicholasb, if you're using a Windows Installer based project you can just put the DLL in the Binary table then the Windows Installer will handle the extract & loading of your DLL.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 18, 2007
06:41 PM
I didn't know that klacounte. Thanks.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 19, 2007
02:25 AM
Hi,
Previously i was having problems when i tried to load a DLL from the SUPPORTDIR directly. IS was unable to load the DLL.
We solved it by copying that DLL first to the system32 directory and then loading the dll from there.
Ur Customaction should do following:
1) Check for existence of DLL in system32.
2) If it exists delete that DLL.
3) Copy that DLL from SUPPORTDIR to system32.
4) Load DLL
5) Do whatever u want,,,,,,,
.
.
)Unload DLL
)Delete the DLL from system32.
Hope it helps,
Santhosh
Previously i was having problems when i tried to load a DLL from the SUPPORTDIR directly. IS was unable to load the DLL.
We solved it by copying that DLL first to the system32 directory and then loading the dll from there.
Ur Customaction should do following:
1) Check for existence of DLL in system32.
2) If it exists delete that DLL.
3) Copy that DLL from SUPPORTDIR to system32.
4) Load DLL
5) Do whatever u want,,,,,,,
.
.
)Unload DLL
)Delete the DLL from system32.
Hope it helps,
Santhosh
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 19, 2007
07:53 AM
Thank you guy for these information! I'll try them today and give you news right here!
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 19, 2007
09:54 AM
Chikura wrote:
We solved it by copying that DLL first to the system32 directory and then loading the dll from there.
You can load a dll from any location as long as you specify the full path to the dll. Following this link for more info LoadLibrary Function. Copying the dll to the System32 directory works because that is in the dll search path but I would not recommend it. See this link for dll search order Dynamic-Link Library Search Order.
If your dll loads other dll's from that same directory then you'll need to call SetDllDirectory on XP SP1 or higher or SetCurrentDirectory on any other OS.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 19, 2007
12:53 PM
I tried your suggestion and well, I think I missed something somewhere.. I'm sorry, but I got more questions.
I put my file in the supportdir and I loaded the DLL using UseDLL in an Installscript CA. The UseDll function worked fine, but I couldn't call my function... I think an exception occurs when I call the function. Do you have an example code on how to call a function in an external dll. The example along with the UseDll example isn't enough for me. Here is my function definition : extern "C" __declspec(dllexport) int __stdcall TestDll( int pOut )
Also, I explored the idea of putting my dll in the binary table. But here, I don't see where to put it in the project. I did not find the folder.
Thanks guys!
I put my file in the supportdir and I loaded the DLL using UseDLL in an Installscript CA. The UseDll function worked fine, but I couldn't call my function... I think an exception occurs when I call the function. Do you have an example code on how to call a function in an external dll. The example along with the UseDll example isn't enough for me. Here is my function definition : extern "C" __declspec(dllexport) int __stdcall TestDll( int pOut )
Also, I explored the idea of putting my dll in the binary table. But here, I don't see where to put it in the project. I did not find the folder.
Thanks guys!
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 19, 2007
01:33 PM
Did you prototype the DLL function before calling it. The prototype should look something like:
prototype MyDLL.MyFunction( INT, INT, INT );
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 19, 2007
02:05 PM
You mean that the prototype for function
(??) What is the argument pOut and what is the return value of the function ? And why the third int ? I would have declared my function that way :
extern "C" __declspec(dllexport) int __stdcall TestDll( int pOut )in gaga.dll should be
prototype gaga.TestDll( INT, INT, INT );
(??) What is the argument pOut and what is the return value of the function ? And why the third int ? I would have declared my function that way :
prototype INT cdkc.TestDll( INT );
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 19, 2007
02:42 PM
That was a sample from the help. The point was that you had to prototype your DLL function in InstallScript prior to calling it. Substitute you DLL name for MyDll, you function name for MyFunction, and list whatever your paramters are in the parameter list.
![](/skins/images/A5EADE085F77DE82FB3B14D6B307AE6A/responsive_peak/images/icon_anonymous_message.png)