Hello everywhere,
maybe you know the function Environ in VB6 where you can get system variables.
e.g. the windows-directory or the temp-path.
Environ has the following Syntax:
Environ({envstring | number})
The Environ function syntax has these named arguments:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
|
Part Description
_________________________________________________
envstring Optional. String expression containing
the name of an environment variable.
number Optional. Numeric expression corresponding to the
numeric order of the environment string
in the environment-string table.
The number argument can be any numeric
expression, but is rounded to a whole
number before it is evaluated.
|
in VB6 you can use this function like in the following code snippet:
Form:
CommandButton: Command1
ListBox: List1
TextBox: Text1, Text2
|
Jabaco Source
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
Private Sub Command1_Click()
Dim X As Integer
Dim Buffer As String
For X = 1 To 34
Buffer = Environ$(X)
If Len(Buffer) <> 0 Then
List1.AddItem Buffer
End If
Next
End Sub
Private Sub List1_Click()
Dim s As String: s = List1.List(List1.ListIndex)
Dim sa() As String: sa = Split(s, "=")
Text1.Text = sa(0)
'here again we ask the Environ-function to see the difference between
'calling it with a number and with a string
Text2.Text = Environ(sa(0))
End Sub
|
afair this function is not availible in the Jabaco framework until now:
|
Jabaco Source
|
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
|
Option Explicit
Private Sub Command1_Click()
Dim i As Integer
Dim Buffer As String
For i = 1 To 34
Buffer = Environ(i)
If Buffer <> Nothing Then
List1.AddItem Buffer
End If
Next
End Sub
Public Sub List1_Click()
Dim s As String = List1.List(List1.ListIndex)
Dim sa() As String
sa = Split(s, "=")
Text1.Text = sa(0)
' here again we ask the Environ function to see the difference
' between calling it with a number or with a string
Text2.Text = Environ(sa(0))
End Sub
Public Function Environ(var) As String
Dim se As String
Dim vt As VBVarType
vt = VarType(var)
If vt = vbString Then
se = CStr(var)
Else
Dim v As Integer
v = CInt(var)
Select Case v
Case 1: se = "ALLUSERSPROFILE"
Case 2: se = "APPDATA"
Case 3: se = "CLASSPATH"
Case 4: se = "CLIENTNAME"
Case 5: se = "CommonProgramFiles"
Case 6: se = "COMPUTERNAME"
Case 7: se = "ComSpec"
Case 8: se = "FP_NO_HOST_CHECK"
Case 9: se = "HOMEDRIVE"
Case 10: se = "HOMEPATH"
Case 11: se = "INCLUDE"
Case 12: se = "LANG"
Case 13: se = "LIB"
Case 14: se = "LOGONSERVER"
Case 15: se = "NUMBER_OF_PROCESSORS"
Case 16: se = "OS"
Case 17: se = "Path"
Case 18: se = "PATHEXT"
Case 19: se = "PROCESSOR_ARCHITECTURE"
Case 20: se = "PROCESSOR_IDENTIFIER"
Case 21: se = "PROCESSOR_LEVEL"
Case 22: se = "PROCESSOR_REVISION"
Case 23: se = "ProgramFiles"
Case 24: se = "QTJAVA"
Case 25: se = "SESSIONNAME"
Case 26: se = "SystemDrive"
Case 27: se = "SystemRoot"
Case 28: se = "TEMP"
Case 29: se = "TMP"
Case 30: se = "USERDOMAIN"
Case 31: se = "USERNAME"
Case 32: se = "USERPROFILE"
Case 33: se = "VSCOMNTOOLS"
Case 34: se = "windir"
End Select
End If
Try: On Error Goto Catch
If se <> Nothing Then
If vt = vbString Then
Environ = System.getenv(se)
Else
Environ = se & "=" & System.getenv(se)
End If
Else
Environ = Nothing
End If
Exit Sub
Catch:
Environ = Nothing
End Function
|
greetings
OlimilO