首页 | 旅游 | 健康 | 时尚 | 下载 | 论坛 | 图文 | 专题 | 地图
资讯 IT人 电脑入门 操作系统 上网 办公 技巧 硬件 软件 网络 图像 多媒体 程序 数据库 网页制作 网站开发 网游 安全 加密 企业

在IIS中建立WEB站点的例子!

巧巧读书 2007-12-16   技术论坛

  Public Sub CreateIISWebServer()
Dim obj As Object
Dim Web, NewWeb, Child, VirDir As Object
Dim SBinds()
Dim Ip, HostName, IIsInstallPath As String
Ip = "192.168.0.1" 'IP地址
HostName = "www.HostName.com" '主机头
IIsInstallPath = "c:\Inetpub\MyWebPath" '目录路径
Dim WebName, i, Port As Integer
WebName = 1
Port = 80 '侦听端口
On Error Resume Next
Err.Clear
Set Web = GetObject("IIS://LocalHost/W3SVC")

Do While Err.Number <> 0
If MsgBox("本服务器Internet Iformation Server 未启动,请启动后重试。", vbRetryCancel, "IIS服务未启动") = vbCancel Then End
Err.Clear
Set Web = GetObject("IIS://LocalHost/W3SVC")
Loop
Err.Clear
For Each Child In Web
If IsNumeric(Child.Name) Then
If CInt(Child.Name) >= WebName Then WebName = CInt(Child.Name) + 1
End If
Next
Set NewWeb = Web.Create("IIsWebServer", WebName)
NewWeb.servercomment = "站点说明"
NewWeb.KeyType = "IIsWebServer"
ReDim SBinds(0)
SBinds(0) = Ip & ":" & Port & ":" & HostName
NewWeb.ServerBindings = SBinds
NewWeb.accessread = True
NewWeb.frontPageWeb = True
NewWeb.EnableDefaultDoc = True
NewWeb.DefaultDoc = "Default.htm, Default.asp, Index.htm, Index.asp"
NewWeb.AccessScript = True
NewWeb.AccessExecute = True
Set VirDir = NewWeb.Create("IIsWebVirtualDir", "Root")
VirDir.Path = IIsInstallPath
VirDir.AppCreate "TRUE"
VirDir.setinfo
NewWeb.setinfo
NewWeb.start

End Sub

Private Sub Command1_Click()
CreateIISWebServer
End Sub

本类最热图文
巧巧读书图文推荐
Google
巧巧电脑频道编辑信箱  告诉我们您想看的专题或文章