首页  编辑  

ActiveX控件的License控制

Tags: /超级猛料/COM、ActiveX,DDE/   Date Created:
ActiveX 控件的License控制
If you want to add licensing to an ActiveForm control after you've created the control, or you want to change the generated license key, here is what you must do.    
   
Go to the Initialization section of the control, it should look like this,      
   
initialization      
 TActiveFormFactory.Create(      
   ComServer,      
   TActiveFormControl,      
   TActiveFormX,      
   Class_ActiveFormX,      
   1,      
   '', // license key goes here!!    
   OLEMISC_SIMPLEFRAME or OLEMISC_ACTSLIKELABEL,      
   tmApartment);      
   
The empty string is used to hold the licensing key.  If you had the key auto-generated by Delphi this will be a GUID.  Enter what-ever you want as the key (must be a string).    
   
Next you must create a lic file.  The name should be the same as your control's file name.    
   
Example:    
 MyControl.ocx    
 MyControl.lic    
   
Open the file with your favorite test editor (this could be Notepad or event Delphi), the file will contain 2 lines.      
   
The first line will be the libraries GUID.  To get this GUID, open up the TypeLibrary editor, click on the top-most node (should be a blue icon that looks like something from Quebert), the Delphi editor refers to these as Modules.  In the panel on the right will be the GUID that you need.  Copy the hole thing (including the brackets).    
   
The second line contains your license key.    
   
When you are done the lic file should look like this    
   
{C874878F-9008-11D4-B838-0050DA72DCF6}    
MyLicenseKey    
   
   
Note: If you send this control to another developer to use you will also have to send the lic file.  It should reside in the same directory as the control.    
   
Note2: If you are distributing this control as part of an application do not include the lic file.  The licensing information to run the control is compiled into the executable.