NETBOX-带错误提示及弹出窗的随机端口代码

Dim httpd

Shell.Service.icon = '\4088738\on.gif' '------这个是你自己设置的图标,对于不会更改图标的朋友可以直接按照这个来做

Shell.Service.RunService 'NBWeb', '测试', '我的空间'

'---------------------- 服务事件开始 ---------------------

Sub OnServiceStart()

    Shell.Service.SetTimer 100

    Set httpd = CreateObject('NetBox.HttpServer')

    If httpd.Create('', 0) = 0 Then

        Set host = httpd.AddHost('', '')

        host.EnableWrite=false

        host.EnableScript = true

        host.AddDefault 'default.asp'

        host.AddDefault 'default.htm'

        host.AddDefault 'default.html'

        host.AddDefault 'index.asp'

        host.AddDefault 'index.htm'

        host.AddDefault 'index.html'

        httpd.Start

Set htWin= CreateObject('NetBox.HtmlWindow')

     htWin.Open 'http://127.0.0.1/ '------这个是随机的端口自动打开的页面

     htWin.ShowDialog

    else

    Shell.MsgBox '你的端口已经被占用,请关闭其他程序后再使用','xx主页 http://www.xxx.net/' '------这是当你遇到端口占用时的提示

        Shell.Quit 0

    end if

End Sub

Sub OnServiceStop()

    httpd.Close

End Sub

Sub OnServicePause()

    Shell.Service.Icon = '\4088738\off.gif'

    Shell.MsgBox '服务器暂停运行!需要时记得打开哦!','xx主页 http://www.xxx.net/' '------这个是当你程序暂停时的提示

    httpd.Stop

End Sub

Sub OnServiceResume()

    httpd.Start

End Sub

Sub OnServiceTimer

If Shell.Service.icon = '\4088738\on.gif' Then

Shell.Service.icon = '\4088738\on1.gif'

Else

Shell.Service.icon = '\4088738\on.gif'

End If

End Sub

你可能感兴趣的:(net)