1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "TGSEntity"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit

Private m_hEntity As Long
Private m_license As TGSLicense
'[INTERNAL ] ******************************* Native Low-Level API *********************************************

Private Declare Function gsGetEntityAttributes Lib "gsCore.dll" Alias "#13" (ByVal hEntity As Long) As Long
Private Declare Function gsGetEntityId Lib "gsCore.dll" Alias "#14" (ByVal hEntity As Long) As Long
Private Declare Function gsGetEntityName Lib "gsCore.dll" Alias "#15" (ByVal hEntity As Long) As Long
Private Declare Function gsGetEntityDescription Lib "gsCore.dll" Alias "#16" (ByVal hEntity As Long) As Long

Private Declare Function gsBeginAccessEntity Lib "gsCore.dll" Alias "#20" (ByVal hEntity As Long) As Byte
Private Declare Function gsEndAccessEntity Lib "gsCore.dll" Alias "#21" (ByVal hEntity As Long) As Byte

Private Declare Function gsOpenLicense Lib "gsCore.dll" Alias "#137" (ByVal hEntity As Long) As Long



'============================== Internal Properties ====================================
Friend Property Let handle(hEntity As Long)
'[INTERNAL]

  m_hEntity = hEntity
  
  Set m_license = New TGSLicense
  m_license.handle = gsOpenLicense(m_hEntity)
End Property

Friend Property Get handle() As Long
'[INTERNAL]
  handle = m_hEntity
End Property


'============================== Public Properties ====================================

Friend Property Get Name() As String
  Name = PCharToStr(gsGetEntityName(m_hEntity))
End Property

Friend Property Get id() As String
  id = PCharToStr(gsGetEntityId(m_hEntity))
End Property

Friend Property Get Description() As String
  Description = PCharToStr(gsGetEntityDescription(m_hEntity))
End Property

Friend Property Get IsAutoStart() As Boolean
'AutoStart Entity: If wrapped, the BeginAccess() is called automatically by SoftwareShield Runtime when app launching
  IsAutoStart = gsGetEntityAttributes(m_hEntity) And &H10
End Property

Friend Property Get License() As TGSLicense
  Set License = m_license
End Property

Friend Property Get Unlocked() As Boolean
  Unlocked = License.IsActivated
End Property

Friend Property Get Locked() As Boolean
  Locked = License.IsDeactivated
End Property


'============================== Public Methods ====================================
Friend Function BeginAccess() As Boolean
  BeginAccess = gsBeginAccessEntity(m_hEntity) <> 0
End Function

Friend Function EndAccess() As Boolean
  EndAccess = gsEndAccessEntity(m_hEntity) <> 0
End Function


Private Sub Class_Terminate()
  Set m_license = Nothing
  Call gsCloseHandle(m_hEntity)
End Sub