|
|
> Linking To ClientProtector In Your Application > Linking To ClientProtector™ Using Microsoft VB.NET® Linking To ClientProtector™ Using Microsoft VB.NET®Please be sure you have read Linking To The ClientProtector COM Component In Your Application before you perform this procedure. If you run into trouble, you may prefer to start with the Sample Code. There are a set of three complete compile-able Visual Basic.NET programs available. The following example was prepared and tested in Microsoft Visual Studio .NET 2003 in the Visual Basic language. The method we use here involves using the interoperability mechanism available to .NET applications to use the ClientProtector COM server just like it was another object in our application. This is a breeze in MSVB. For additional information you may wish to see the MSDN page "Calling COM Components from .NET Clients". 1. Open Microsoft Visual Studio .NET. Open a new or existing Visual Basic project to which you want to use the ClientProtector. 2. In the Solution Explorer window select the project and right-click it and select "Add Reference". (You can also do this from the "Project" menu.) 3. The "Add References" dialog will appear. Select the "COM" tab. in the component grid, find the "SoftwareShield ClientProtector" and select it. Click the "Select" button. It will appear in the "Selected Components" grid at the bottom of the dialog. Click "OK". If you have the debug version registered it will say "SoftwareShield DEBUG ClientProtector" - that's OK. The dialog is shown below: 4. In the main form of your application, insert the "imports" directive to use the imported ClientProtector namespace, like this: Imports SSCProt 5. In the main form of your application, declare a member of the ClientProtector type and create the object like this: ' the ClientProtector server 6. In the Form-Load event of the main form, initialize the object by calling its start up function. All that looks like this: ' lets make sure the ClientProtector COM server is still registered on this machine. Err.Clear() On Error Resume Next If Err.Number Then ' if its not - inform the user of the problem and shut down. MsgBox("Unable to connect to the license server. Please contact your vendor.") Application.Exit() Exit Sub End If
Dim debugFlags As Long Dim return_code As Long
debugFlags = 0 Dim MainLicenseFileName, MainLicenseFilePassword, _ GlobalAuthorizationCodePassword, FingerPrintOptionsCode As String
MainLicenseFilePassword = "austrian_6_abode_._epitome" GlobalAuthorizationCodePassword = "featuring_CAMPANILE_2_newscast" FingerPrintOptionsCode = 6553703 MainLicenseFileName = "..\CPFeaturesSample.ini"
' initialize the ClientProtector and Start it up SSCP.StartUp(MainLicenseFileName, MainLicenseFilePassword, _ GlobalAuthorizationCodePassword, FingerPrintOptionsCode, _ debugFlags, return_code)
When you use the ”Imports SSCProt"
directive, the IDE also has visibility to the enumerated constants defined
in RETURNCODES and CPDEBUGFLAGS (inside COM server). You have access to
these defined constants directly.
|