1
2 Dim httpd
3
4 dim Path
5
6 Dim ServerPort
7
8 Dim b_createport
9
10
11
12 path =NetBox.ApplicationPath
13
14 NetBox.ConfigFile = path & "main.ini"
15
16 ServerPort = netBox.Config("Server","Port")
17
18
19
20 Set httpd = NetBox.CreateObject("NetBox.HttpServer")
21
22 IF ServerPort="" THen
23
24 ServerPort = 80
25
26 netBox.Config("Server","Port") = ServerPort
27
28 End If
29
30
31
32 Shell.Service.Icon = path & netBox.Config("config","ICON")
33
34 Shell.Service.RunService "NBWeb", "NetBox Web Server", "NetBox Http Server Sample"
35
36
37
38 Sub CreatePort()
39
40 ServerPort = 0
41
42 Do While (ServerPort<1025 Or ServerPort>65535)
43
44 If httpd.Create("", 0) = 0 Then
45
46 If httpd.LocalPort > 1024 and httpd.LocalPort < 65535 Then
47
48 ServerPort=httpd.LocalPort
49
50 End If
51
52 End If
53
54 Loop
55
56 End Sub
57
58
59
60 Sub OnServiceStart()
61
62 Set service = Shell.Service
63
64 If httpd.Create("", ServerPort) = 0 Then
65
66 If b_createport = true Then
67
68 Dim b_SaveConfig
69
70 b_SaveConfig = Shell.MsgBox ("练习系统检测到目前分配到的端口[" & ServerPort & "]可以使用,是否保存?","保存端口",33)
71
72 If b_SaveConfig = 1 Then
73
74 netBox.Config("Server","Port") = ServerPort
75
76 End If
77
78 End If
79
80 Set host = httpd.AddHost("", "\wwwroot")
81
82 ‘Set host1 = host.AddFolder("WebExam","\WebExam")
83
84 host.EnableScript = true
85
86 host.AddDefault "default.asp"
87
88 host.AddDefault "default.htm"
89
90 httpd.Start
91
92 Shell.Execute """" & NetBox.SysInfo("Folder_ProgramFiles") & "\Internet Explorer\IEXPLORE.EXE"" http://localhost:"&ServerPort&"/Your App"
93
94 else
95
96 Shell.MsgBox "练习系统检测到要使用的端口[" & ServerPort & "]已被别的程序占用,系统将重新分配端口!点击确定继续", "提示信息",64
97
98 b_createport = true
99
100 CreatePort
101
102 OnServiceStart
103
104 end if
105
106 End Sub
107
108
109
110 Sub OnServiceStop()
111
112 httpd.Close
113
114 Shell.Halt 0
115
116 Shell.Quit 0
117
118 End Sub
119
120
121
122 Sub OnServicePause()
123
124 httpd.Stop
125
126 End Sub
127
128
129
130 Sub OnServiceResume()
131
132 httpd.Start
133
134 End Sub
2 Dim httpd
3
4 dim Path
5
6 Dim ServerPort
7
8 Dim b_createport
9
10
11
12 path =NetBox.ApplicationPath
13
14 NetBox.ConfigFile = path & "main.ini"
15
16 ServerPort = netBox.Config("Server","Port")
17
18
19
20 Set httpd = NetBox.CreateObject("NetBox.HttpServer")
21
22 IF ServerPort="" THen
23
24 ServerPort = 80
25
26 netBox.Config("Server","Port") = ServerPort
27
28 End If
29
30
31
32 Shell.Service.Icon = path & netBox.Config("config","ICON")
33
34 Shell.Service.RunService "NBWeb", "NetBox Web Server", "NetBox Http Server Sample"
35
36
37
38 Sub CreatePort()
39
40 ServerPort = 0
41
42 Do While (ServerPort<1025 Or ServerPort>65535)
43
44 If httpd.Create("", 0) = 0 Then
45
46 If httpd.LocalPort > 1024 and httpd.LocalPort < 65535 Then
47
48 ServerPort=httpd.LocalPort
49
50 End If
51
52 End If
53
54 Loop
55
56 End Sub
57
58
59
60 Sub OnServiceStart()
61
62 Set service = Shell.Service
63
64 If httpd.Create("", ServerPort) = 0 Then
65
66 If b_createport = true Then
67
68 Dim b_SaveConfig
69
70 b_SaveConfig = Shell.MsgBox ("练习系统检测到目前分配到的端口[" & ServerPort & "]可以使用,是否保存?","保存端口",33)
71
72 If b_SaveConfig = 1 Then
73
74 netBox.Config("Server","Port") = ServerPort
75
76 End If
77
78 End If
79
80 Set host = httpd.AddHost("", "\wwwroot")
81
82 ‘Set host1 = host.AddFolder("WebExam","\WebExam")
83
84 host.EnableScript = true
85
86 host.AddDefault "default.asp"
87
88 host.AddDefault "default.htm"
89
90 httpd.Start
91
92 Shell.Execute """" & NetBox.SysInfo("Folder_ProgramFiles") & "\Internet Explorer\IEXPLORE.EXE"" http://localhost:"&ServerPort&"/Your App"
93
94 else
95
96 Shell.MsgBox "练习系统检测到要使用的端口[" & ServerPort & "]已被别的程序占用,系统将重新分配端口!点击确定继续", "提示信息",64
97
98 b_createport = true
99
100 CreatePort
101
102 OnServiceStart
103
104 end if
105
106 End Sub
107
108
109
110 Sub OnServiceStop()
111
112 httpd.Close
113
114 Shell.Halt 0
115
116 Shell.Quit 0
117
118 End Sub
119
120
121
122 Sub OnServicePause()
123
124 httpd.Stop
125
126 End Sub
127
128
129
130 Sub OnServiceResume()
131
132 httpd.Start
133
134 End Sub
浙公网安备 33010602011771号