Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

license checking inside Class_Initialize()

Posted on 2005-05-17
1
Medium Priority
?
225 Views
Last Modified: 2008-03-10
I have a VB6 dll that contains a lot of the functions for my asp application. I need to put a license key check inside the dll in order to prevent the app from running if a valid key is not found, or if it's expired.

I would like to put this check inside Class_Initialize() so that it is only executed once -- when the object is created. Is there any danger in this, or pitfalls I should be aware of? Would this create instability in the component or webapp? Is there a better solution? Are there certain types of code that should not be executed inside Class_Initialize()?

Can Class_Initialize() return a value to signify expired or invalid key? Or can it call a function to do so? If not, how can I alert the calling asp page that this is the case?

I will split points for any useful responses.
0
Comment
Question by:SweatCoder
1 Comment
 
LVL 28

Accepted Solution

by:
AzraSound earned 2000 total points
ID: 14022117
I don't see any issues using Class_Initialize.  I have used it for my own license checking in my components.  There is no way to return a value directly, but you can fill a variable made accessible via a public property that can be accessed once the component is created, e.g.,



Private m_blnLicenseValid As Boolean

Public Property Get LicenseValid() As Boolean
    LicenseValid = m_blnLicenseValid
End Property


Private Sub Class_Initialize()
    'ensure initially false
    m_blnLicenseValid = False

    'do license checking
    'fill m_blnLicenseValid with results
End Sub




From ASP:

Dim obj

Set obj = Server.CreateObject("MyDLL.MyClass")
If obj.LicenseValid = False Then
    Response.Write "Invalid License"
Else
    'proceed with ASP code
End If
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question