关于NetBox2.8端口问题

来源:互联网 发布:膺惩暴支 知乎 编辑:程序博客网 时间:2024/05/20 06:24
这几天公司在搞单机练习版(asp程序),为了封装程序,使用的是netbox2.8.在端口问题上给技术支持带的压力挺大.
我们自己定一个端口,到了用户那里,可能该端口已被占用.
由于Netbox已经停止开发了,没有任何的技术支持.所以只有自己去研究了.发现netbox的语言,和VB极为类似,可以说就是VB的语法,
加入了Netbox自己的对象而已.昨天解决了以后今天又优化了一下,我想应该是没有任何问题了.
Dim httpddim Path Dim ServerPortDim b_createportpath =NetBox.ApplicationPathNetBox.ConfigFile = path & "main.ini"ServerPort = netBox.Config("Server","Port")Set httpd = NetBox.CreateObject("NetBox.HttpServer")IF ServerPort="" THen    ServerPort = 80    netBox.Config("Server","Port") = ServerPortEnd IfShell.Service.Icon = path & netBox.Config("config","ICON")Shell.Service.RunService "NBWeb", "NetBox Web Server", "NetBox Http Server Sample"Sub CreatePort()    ServerPort = 0    Do While (ServerPort<1025 Or ServerPort>65535)        If httpd.Create("", 0) = 0  Then            If httpd.LocalPort > 1024 and  httpd.LocalPort < 65535 Then                ServerPort=httpd.LocalPort            End If        End If    LoopEnd SubSub OnServiceStart()    Set service = Shell.Service    If httpd.Create("", ServerPort) = 0 Then    If b_createport = true Then        Dim b_SaveConfig        b_SaveConfig = Shell.MsgBox ("练习系统检测到目前分配到的端口[" & ServerPort & "]可以使用,是否保存?","保存端口",33)        If b_SaveConfig = 1 Then            netBox.Config("Server","Port") = ServerPort        End If    End If        Set host = httpd.AddHost("", "/wwwroot")    ‘Set host1 = host.AddFolder("WebExam","/WebExam")        host.EnableScript = true        host.AddDefault "default.asp"        host.AddDefault "default.htm"        httpd.Start    Shell.Execute """" & NetBox.SysInfo("Folder_ProgramFiles") & "/Internet Explorer/IEXPLORE.EXE"" http://localhost:"&ServerPort&"/Your App"    else    Shell.MsgBox "练习系统检测到要使用的端口[" & ServerPort & "]已被别的程序占用,系统将重新分配端口!点击确定继续", "提示信息",64    b_createport = true    CreatePort    OnServiceStart    end ifEnd SubSub OnServiceStop()    httpd.Close    Shell.Halt 0    Shell.Quit 0End SubSub OnServicePause()    httpd.StopEnd SubSub OnServiceResume()    httpd.StartEnd Sub