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
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "TGS"
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

'[INTERNAL ] ******************************* Native Low-Level API *********************************************
Private Declare Function gsGetVersion Lib "gsCore.dll" Alias "#2" () As Long
Private Declare Function gsRunInWrappedMode Lib "gsCore.dll" Alias "#81" () As Byte
Private Declare Function gsRunInsideVM Lib "gsCore.dll" Alias "#82" (ByVal vmMask As Long) As Byte
Private Declare Function gsIsDebugVersion Lib "gsCore.dll" Alias "#91" () As Byte


Public Enum GSErr
    CANNOT_INIT_CORE = 1
    ENTITY_OPEN_FAILURE = 2
    VARIABLE_INVALID_VALUE = 3
    VARIABLE_NOT_FOUND = 4
    LICENSEPARAM_OPEN_FAILURE = 5
    REQUEST_CREATE_FAILURE = 6
    ACTION_CREATE_FAILURE = 7
    MVPKG_CREATE_FAILURE = 8
    MVPKG_UPLOAD_FAILURE = 9
End Enum

'local variable(s) to hold property value(s)
Private mvarProductId As String 'local copy
Private mvarPassword As String 'local copy
Private mvarLicenseFile As String 'local copy

Friend Property Let LicenseFile(ByVal vData As String)
'Full path to the license file
'If it is not a full path, SDK will try to find the license file side by side with the application exe
    mvarLicenseFile = vData
End Property

Friend Property Let Password(ByVal vData As String)
'The main license file's password
    mvarPassword = vData
End Property

Friend Property Let ProductId(ByVal vData As String)
'The license project's product Id
    mvarProductId = vData
End Property


Friend Static Property Get App() As TGSApp
'Singleton App Object (gs.App)
  Dim s_app As TGSApp
  
  If s_app Is Nothing Then
    Set s_app = New TGSApp
  End If
  
  Set App = s_app
End Property

Friend Static Property Get Core(Optional ByVal CreateIfNonExistent As Boolean = True) As TGSCore
'Singleton Core Object (gs.Core)
    Dim s_core As TGSCore
    Dim errCode As Integer
    
    If s_core Is Nothing Then
        Set s_core = New TGSCore
        errCode = s_core.Init(mvarProductId, mvarLicenseFile, mvarPassword)
        If 0 <> errCode Then
            err.Raise vbObjectError + GSErr.CANNOT_INIT_CORE, "gs", s_core.LastErrorMessage
        End If
    End If
        
    Set Core = s_core
End Property

Friend Property Get SDKVersion() As String
'The SDK version being used
  Dim ver As Long
  ver = gsGetVersion()
  SDKVersion = PCharToStr(ver)
End Property

Friend Property Get RunInWrappedMode() As Boolean
'Test if the current process is running inside GS5 Ironwrapper runtime
'Returns false when the running app is not wrapped
  RunInWrappedMode = (gsRunInWrappedMode() <> 0)
End Property

Friend Property Get RunInVM() As Boolean
'    Test if the current process is runing inside any virtual machine (VMWare / VirtualPC / VirtualBox /Fusion /Parallel / QEMU).
  RunInVM = (gsRunInsideVM(-1) <> 0)
End Property

Friend Property Get IsDebugVersion() As Boolean
' Is current SDK binary a debugger version?
  IsDebugVersion = (gsIsDebugVersion() <> 0)
End Property


'[INTERNAL]
Friend Sub cleanUp()
   Dim mycore As TGSCore
      
   Set mycore = Me.Core(False)
   If Not mycore Is Nothing Then
        mycore.cleanUp
   End If
End Sub