/[AnywhereTS-MSSQL]/trunk/VBDLL/Settings.vb
ViewVC logotype

Contents of /trunk/VBDLL/Settings.vb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (show annotations) (download)
Wed Jul 11 14:19:13 2012 UTC (8 years, 1 month ago) by william
File size: 8348 byte(s)
imported from https://anywherets.svn.sourceforge.net/svnroot/anywherets/trunk/
Revision: 1
Author: beartown
Date: 3:10:40 AM, Monday, June 21, 2010
Message:
First upload. Still todo in order to get a fully working product: Replace Thinstation images with vanilla Thinstation, modify ImageDesigntimeConfig.cs, ImageRuntimeConfig.cs in order to support the Thinstation image
1 Public Module Settings
2
3 Public Sub OpenRegistry()
4 GetTFTPdirectory()
5 Dim objRegkey As Microsoft.Win32.RegistryKey
6 'Check for registry key if this is first time
7 'It's OK if the key doesn't exist; we'll write it later
8 On Error GoTo NoRegKeyFirst 'Reading Registry without permission throws error. Ignore.
9 objRegkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\AnywhereTS\ts-config")
10 If (objRegkey Is Nothing) Then
11 #If PRO Then
12 #Else
13 Globals.bolDhcpNotInst = True ' The first time we run the app.
14 #End If
15 Globals.bolCheckForUpdates = True
16 Else
17 If objRegkey.GetValue("CheckUpdate") = 0 Then
18 Globals.bolCheckForUpdates = False
19 Else
20 Globals.bolCheckForUpdates = True
21 End If
22 End If
23 NoRegKeyFirst:
24 On Error GoTo NoRegKeySecond
25 objRegkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\AnywhereTS\ts-config")
26 If Not (objRegkey Is Nothing) Then
27 If Not (objRegkey.GetValue("CheckUpdate") Is Nothing) Then
28 If objRegkey.GetValue("CheckUpdate") = 0 Then
29 Globals.bolCheckForUpdates = False
30 Else
31 Globals.bolCheckForUpdates = True
32 End If
33 Else
34 Globals.bolCheckForUpdates = True 'if reg key "ts-config" exists, but regkey "CheckUpdate" is missing
35 End If
36 If Not (objRegkey.GetValue("appdir") Is Nothing) Then
37 Globals.strAppdir = objRegkey.GetValue("appdir")
38 End If
39 If (objRegkey.GetValue("dhcp_check") = 0) Then
40 #If PRO Then
41 #Else
42 Globals.bolDhcpNotInst = True ' The first time we run the app.
43 #End If
44 End If
45
46 End If
47 NoRegKeySecond:
48 On Error GoTo 0
49 If Globals.strAppdir Is Nothing Then
50 Globals.strAppdir = System.IO.Path.GetDirectoryName(Application.ExecutablePath)
51 End If
52 End Sub
53 'Check for the TFTPD path in registry.
54 Public Function GetTFTPdirectory() As String
55 Dim objRegkey As Microsoft.Win32.RegistryKey
56
57 'Check for registry key for TFTP directory
58 Globals.strTFTPdir = Nothing
59 On Error GoTo NoRegKey1 'Reading registry without permission throws error. Ignore.
60 'Check for MS TFTP first
61 objRegkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\AnywhereTS\ts-config")
62 If Not (objRegkey Is Nothing) Then
63 If Not (objRegkey.GetValue("TFTP_root") Is Nothing) Then
64 Globals.strTFTPdir = objRegkey.GetValue("TFTP_root").ToString
65 Console.WriteLine("HKLM=" + Globals.strTFTPdir)
66 End If
67 End If
68 NoRegKey1:
69 On Error GoTo NoRegKey2
70 'Check current user
71 If Globals.strTFTPdir Is Nothing Then
72 objRegkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\AnywhereTS\ts-config")
73 If Not (objRegkey Is Nothing) Then
74 If Not (objRegkey.GetValue("TFTP_root") Is Nothing) Then
75 Globals.strTFTPdir = objRegkey.GetValue("TFTP_root").ToString
76 Console.WriteLine("CURRENT_USER=" + Globals.strTFTPdir)
77 End If
78 End If
79 End If
80 NoRegKey2:
81 On Error GoTo -1
82
83 If Globals.strTFTPdir Is Nothing Then
84 Globals.strTFTPdir = strAppdir + "\TFTP_root"
85 Console.WriteLine("tftpdir=" + Globals.strTFTPdir)
86 End If
87
88 Return Globals.strTFTPdir
89 End Function
90 'Set the registry keys for TFTPD32. If bolDHCP then enable DHCP, otherwise just TFTP
91 Public Sub SetTFTPD32Regkeys(ByVal bolDHCP As Boolean)
92 Dim objRegkey As Microsoft.Win32.RegistryKey
93
94 On Error GoTo ErrTFTPD32
95 objRegkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\TFTPD32", True)
96 If (objRegkey Is Nothing) Then
97 objRegkey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("SOFTWARE\TFTPD32")
98 End If
99 If (objRegkey Is Nothing) Then GoTo ErrTFTPD32
100 objRegkey.SetValue("LastWindowPos", "60 49 860 642 ")
101 objRegkey.SetValue("BaseDirectory", Globals.strTFTPdir)
102 objRegkey.SetValue("TftpPort", 69)
103 objRegkey.SetValue("Hide", 0)
104 objRegkey.SetValue("WinSize", 0)
105 objRegkey.SetValue("Negociate", 1)
106 objRegkey.SetValue("PXECompatibility", 0)
107 objRegkey.SetValue("DirText", 0)
108 objRegkey.SetValue("ShowProgressBar", 0)
109 objRegkey.SetValue("Timeout", 3)
110 objRegkey.SetValue("MaxRetransmit", 6)
111 objRegkey.SetValue("SecurityLevel", 1)
112 objRegkey.SetValue("UnixStrings", 1)
113 objRegkey.SetValue("Beep", 0)
114 objRegkey.SetValue("VirtualRoot", 1)
115 If Globals.intNoOfValidAdapters = 1 Then
116 objRegkey.SetValue("LocalIP", AtsDhcp.strTftpd32IP)
117 Else
118 objRegkey.SetValue("LocalIP", AtsDhcp.strTftpd32IP)
119 End If
120 If bolDHCP Then
121 objRegkey.SetValue("Services", 5) 'DHCP + TFTP
122 Else
123 objRegkey.SetValue("Services", 1) 'TFTP only
124 End If
125 objRegkey.SetValue("TftpLogFile", "")
126 objRegkey.SetValue("SaveSyslogFile", "")
127 objRegkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\TFTPD32\DHCP", True)
128 If (objRegkey Is Nothing) Then
129 objRegkey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("SOFTWARE\TFTPD32\DHCP")
130 End If
131 If (objRegkey Is Nothing) Then GoTo ErrTFTPD32
132 objRegkey.SetValue("IP_Pool", &H1400DF0A)
133 objRegkey.SetValue("PoolSize", &HC8)
134 objRegkey.SetValue("BootFile", "client.zpxe")
135 objRegkey.SetValue("DNS", &H100DF0A)
136 objRegkey.SetValue("Mask", &HFFFF)
137 objRegkey.SetValue("Gateway", &H100DF0A)
138 objRegkey.SetValue("DomainName", "")
139 objRegkey.SetValue("AddOptionNumber1", 0)
140 objRegkey.SetValue("AddOptionValue1", "")
141 objRegkey.SetValue("AddOptionNumber2", 0)
142 objRegkey.SetValue("AddOptionValue2", "")
143 Return
144
145 ErrTFTPD32:
146 On Error GoTo -1
147 MessageBox.Show("Failed to write to registry. Aborting.", "AnywhereTS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
148 Application.Exit()
149 End Sub
150 'Set the dhcp_check registry key to the intDHCPcheck global variable value
151 Public Sub WriteDHCPRegkey(ByVal intDHCPvalue As Integer)
152 Dim objRegkey As Microsoft.Win32.RegistryKey
153
154 On Error GoTo NoRegWrite
155 objRegkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\AnywhereTS\ts-config", True)
156 If (objRegkey Is Nothing) Then
157 objRegkey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("SOFTWARE\AnywhereTS\ts-config")
158 End If
159 If (objRegkey Is Nothing) Then GoTo NoRegWrite
160 objRegkey.SetValue("dhcp_check", intDHCPvalue)
161 Return
162
163 NoRegWrite:
164 On Error GoTo -1
165 MessageBox.Show("Failed to write to registry. Aborting.", "AnywhereTS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
166 Application.Exit()
167 End Sub
168
169 'Set the CheckUpdate registry key to the intCheckForUpdates global variable value
170 Public Sub WriteCheckUpdatesRegkey()
171 Dim objRegkey As Microsoft.Win32.RegistryKey
172
173 On Error GoTo NoRegWrite
174 objRegkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\AnywhereTS\ts-config", True)
175 If (objRegkey Is Nothing) Then
176 objRegkey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("SOFTWARE\AnywhereTS\ts-config")
177 End If
178 If (objRegkey Is Nothing) Then GoTo NoRegWrite
179 If Globals.bolCheckForUpdates = False Then
180 objRegkey.SetValue("CheckUpdate", 0)
181 Else
182 objRegkey.SetValue("CheckUpdate", 1)
183 End If
184 Return
185
186 NoRegWrite:
187 On Error GoTo -1
188 MessageBox.Show("Failed to write to registry. Aborting.", "AnywhereTS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
189 Application.Exit()
190 End Sub
191
192 End Module

  ViewVC Help
Powered by ViewVC 1.1.22