summaryrefslogtreecommitdiffstats
path: root/src/VBox/Main/testcase/VBoxVBTest/TestForm.frm
blob: 3ba63c8f1de5b90ade547b25720fb7e67bce6a18 (plain)
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
VERSION 5.00
Begin VB.Form TestForm 
   Caption         =   "VirtualBox Test"
   ClientHeight    =   4692
   ClientLeft      =   60
   ClientTop       =   348
   ClientWidth     =   6972
   LinkTopic       =   "TestForm"
   ScaleHeight     =   4692
   ScaleWidth      =   6972
   StartUpPosition =   3  'Windows Default
   Begin VB.ListBox machineList 
      Height          =   2352
      ItemData        =   "TestForm.frx":0000
      Left            =   240
      List            =   "TestForm.frx":0007
      TabIndex        =   4
      Top             =   2040
      Width           =   6492
   End
   Begin VB.CommandButton getMachieListCmd 
      Caption         =   "Get Machine List"
      Height          =   372
      Left            =   2640
      TabIndex        =   0
      Top             =   720
      Width           =   1692
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "Registered Machines:"
      Height          =   192
      Left            =   240
      TabIndex        =   5
      Top             =   1680
      Width           =   1572
   End
   Begin VB.Label versionLabel 
      AutoSize        =   -1  'True
      Caption         =   "<none>"
      Height          =   192
      Left            =   1680
      TabIndex        =   3
      Top             =   1320
      Width           =   528
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "VirtualBox Version:"
      Height          =   252
      Left            =   240
      TabIndex        =   2
      Top             =   1320
      Width           =   1344
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   $"TestForm.frx":0013
      Height          =   372
      Left            =   240
      TabIndex        =   1
      Top             =   120
      Width           =   6492
      WordWrap        =   -1  'True
   End
End
Attribute VB_Name = "TestForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Declare Function SetEnvironmentVariable Lib "kernel32" _
    Alias "SetEnvironmentVariableA" (ByVal lpName As String, ByVal lpValue As String) As Long
Private Declare Function GetEnvironmentVariable Lib "kernel32" _
    Alias "GetEnvironmentVariableA" (ByVal lpName As String, ByVal lpValue As String, ByVal nSize As Long) As Long

Private Sub Form_Load()
    
    ' Set where to take VirtualBox configuration from
    
    'SetEnvironmentVariable "VBOX_USER_HOME", "E:\VirtualBoxHome\win"
    
    ' Setup debug logging (available only in debug builds)
    
    'PATH_OUT_BASE = "D:/Coding/innotek/vbox/out"
    
    'SetEnvironmentVariable "VBOX_LOG", "main.e.l.f + gui.e.l.f"
    'SetEnvironmentVariable "VBOX_LOG_FLAGS", "time tid thread"
    'SetEnvironmentVariable "VBOX_LOG_DEST", "dir:" + PATH_OUT_BASE + "/logs"

End Sub

Private Sub getMachieListCmd_Click()
    
    ' Clear the old list contents
    
    machineList.Clear
    machineList.Refresh
    
    versionLabel.Caption = "<none>"
    
    ' Disable the button and the list for the duration of the call
        
    getMachieListCmd.Enabled = False
    machineList.Enabled = False
        
    ' Obtain the global VirtualBox object (this will start
    ' the VirtualBox server if it is not already started)
    
    Dim vbox As VirtualBox.VirtualBox
    Set vbox = New VirtualBox.VirtualBox
    
    ' Get the VirtualBox server version
    
    versionLabel.Caption = vbox.Version
    
    ' Obtain a list of registered machines
    
    Dim machines() As VirtualBox.IMachine
    machines = vbox.Machines2
    
    If UBound(machines) < 0 Then
        machineList.AddItem ("<none>")
    Else
        For i = 0 To UBound(machines)
            Item = machines(i).Name + " (" + machines(i).OSTypeId() + ")"
            machineList.AddItem (Item)
        Next i
    End If
    
    ' Reenable the button and the list
    
    getMachieListCmd.Enabled = True
    machineList.Enabled = True

End Sub