This article is now superseded by an improved article found here.
[This is a contribution from one of our customer]
I wrote these notes after I configured QLM's Delphi sample program to work with my copy of Delphi. I wanted to share this information with other Delphi programmers to help make it easier for you to get QLM up and running.
I was using Delphi 2010 on 32-bit Vista. The steps that you take may be different depending on your version of Delphi and Windows.
1. Install the trial edition of QLM.
Your Windows user account needs to be set to Administrator to install QLM with no errors. I normally run my Windows user account as Standard, so in my case I had to switch it to Administrator then reboot before installing QLM.
2. Copy the IsLicense50.dll files to the correct locations
I'm not sure why Soraco doesn't do this for you automatically during the QLM installation, but at the time I wrote this they don't. So you need to do it.
Using File Explorer, navigate to the C:\Program Files\Soraco\QuickLicenseManager\Redistrib folder.
Copy (don't cut) the x64 and x86 folders to your Windows clipboard. These folders contain different versions of IsLicense50.dll
Navigate to the ".net 2.0" folder, which is right in front of you under C:\Program Files\Soraco\QuickLicenseManager\Redistrib,
Paste the copies of the x64 and x86 folders so that they become subfolders of the ".net 2.0" folder.
3. Register the QlmLicenseLib.dll assembly on your system
QlmLicenseLib.dll is a .NET assembly file. You do NOT use regsvr32.exe to register it. Instead, you need to use RegAsm.exe.
I created a batch file on my computer to do the deed. The line below is what I put in the batch file:
"C:\Windows\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe" "C:\Program Files\Soraco\QuickLicenseMgr\Redistrib\.net 2.0\QlmLicenseLib.dll" /codebase
NOTE: If your OS is 64 bit and your app is 64 bit, you need to use this path to register QlmLicenseLib.dll:
"C:\Windows\Microsoft.NET\Framework64\v2.0.50727\RegAsm.exe" "C:\Program Files\Soraco\QuickLicenseMgr\Redistrib\.net 2.0\QlmLicenseLib.dll" /codebase
Of course, you should confirm the paths to RegAsm.exe and QlmLicenseLib.dll on your computer and adjust your batch file accordingly.
Note: Even though my user account was set to Administrator status, to make the batch file run properly I had to start the batch file by right-clicking it and selecting RUN AS ADMINISTRATOR.
4. Open the QLM Sample Program for Delphi.
You will find the Delphi QLM Pro sample program at:
C:\Users\Public\Public Documents\Quick License Manager\Samples\qlmpro\Delphi
I copied that folder over to my user account's Documents folder, for easy access and to make sure I maintained an original copy of the sample files in case I messed things up.
In your copy of Delphi, open QLMProSample.dproj
5. Regenerate the QLMLicenseLib_TLB.pas and mscorlib_TLB.pas component wrapper files.
Since I was going to recreate these component wrapper files, first I renamed the ones that shipped with the sample program (call me a hoarder, but I didn't want to overwrite/delete them). So these files...
IsLicense50_TLB.pas
mscorlib_TLB.pas
QlmLicenseLib_TLB.pas
were renamed to...
z_IsLicense50_TLB.pas (Note: This file isn't regenerated in my instructions because it doesn't appear to be needed by QLM. As far as I know, you can rename it and forget it.)
z_mscorlib_TLB.pas
z_QlmLicenseLib_TLB.pas
With the old files safely renamed, here's how to regenerate the component wrapper files:
*** This steps appears to be broken from the Delphi GUI ***
*** If you get an error importing the .NET DLL, proceed with the steps at the end of this section ***
From Delphi's menu select Component > Import Component
Select Import .NET Assembly, then click the NEXT button.
A list is populated with the Registered Assemblies on your computer. This may take a few seconds.
Do NOT select anything in the list of components.
Click the ADD button.
Navigate to C:\Program Files\Soraco\QuickLicenseMgr\Redistrib\.net 2.0 and select QlmLicenseLib.dll.
Click the OPEN button.
The Import Component window shows your selected file in the list.
Click the NEXT button.
I wanted to share the QLM component wrapper files for several Delphi programs, so I wanted the wrappers in a common shared folder. In the Unit Dir Name box, I selected C:\Users\\Documents\RAD Studio\\Imports
Leave the Search Path alone.
Make sure the Generate Component Wrappers box is checked.
Click the NEXT button
Select Add Unit To Project.
Click the FINISH button.
Wait a few seconds for the process to complete. This generates new QLMLIcenseLib_TLB and mscorlib_TLB files in the folder that you specified in the Unit Dir Name box.
*** End of adding .NET component- if this step failed, you can use the following command line tool to regenerate the wrapper code ***
*** Command line way of generating the wrapper classes ***
> tlibimp -P "C:\Program Files\Soraco\QuickLicenseMgr\Redistrib\.net 2.0\QlmLicenseLib.dll"
This will generate a set of classes that you can copy to the project folder.
***
You should be ready to run the sample program. I hope it works for you!
6. Extra Credit
Here are some additional tips to improve the functionality of the QLM Delphi sample program.
A. Closing the license activation form.
I edited two procedures in QlmLicenseFrm.pas as shown below to allow the form to close by clicking the Close button once, rather than twice. Also, setting modalresult in QLMlicenseFrm lets you easily organize how to handle exiting the form and/or program. For example, if an invalid registration key was entered, you could set the ModalResult to mrAbort, show a message then shut down the entire app.
procedure DisplayLicenseForm(Const wsu, cek : String);
var
i:integer;
begin
LicenseForm := TLicenseForm.Create(nil);
// Application.CreateForm(TLicenseForm, LicenseForm);
LicenseForm.webServiceUrl:=wsu;
LicenseForm.communicationEncryptionKey:=cek;
i := LicenseForm.ShowModal();
LicenseForm.Release;
case i of
mrAbort:
begin
ShowMessage('ShowModal result: Abort (due to registration key failed).' +
'You need to enter a valid registration key.');
//Close down the whole application. In this situation, it's
//best to use this method of exiting the program because the main
//form is still not completely created yet, so you can't just
//close that to shut things down.
PostMessage(Application.handle, WM_CLOSE, 0, 0);
end;
mrClose, mrCancel:
//Go back to the main app. Let it finish loading.
ShowMessage('ShowModal Close or Cancel called. Back to the main form we go.');
end;
end; // DisplayLicenseForm
procedure TLicenseForm.btnCloseClick(Sender: TObject);
begin
// Close;
ModalResult := mrClose;
end;
B. Testing for embedded Feature flags
You can add this function to the LicenseValidator.pas file to test the QLM license for enabled features:
function TLicenseValidator.isFeatureEnabled(featureSet: Integer; featureID: Integer): Boolean;
begin
Result := license.IsFeatureEnabledEx(featureSet, featureID);
end;
C. Distribution Note
When you distribute your application, you will need to install QlmLicenseLib.dll on the customer's computer. Soraco recommends that you put it in C:\Program Files\Common Files\Soraco
Then under that folder, create two subfolders, x86 and x64
Into the x86 folder, copy IsLicense50.dll from C:\Program Files\Soraco\QuickLicenseMgr\Redistrib\x86
Into the x64 folder, copy IsLicense50.dll from C:\Program Files\Soraco\QuickLicenseMgr\Redistrib\x64
Finally, as part of your installation routine, you'll need to run RegAsm /codebase on the QlmLicenseLib.dll file to register it on the end user's computer.
I hope that these instructions will help you use QLM with Delphi!
Comments
0 comments
Article is closed for comments.