ASP如何添加或删除主机头。


'===============================================================
'函数名称:AddWebSiteHostName
'函数功能:在已存在的站点中主机头中添加新的主机头
'           index 站点编号
'           NewWebTop 主机头字符串
'开发成员:MMC(mmcgzs@hotmail.com)
'===============================================================
Public Function AddWebSiteHostName(index, NewWebTop)

  On Error Resume Next
 
  Dim tmpwebtop, ztop, oWebServer, tmpstring, Computer
 
  Computer = "localhost"
 
  Set oWebServer = GetObject("IIS://" & Computer & "/w3svc/" & index)
 
  tmpwebtop = oWebServer.serverbindings '''获取原来的主机头
  
  tmpstring = Join(tmpwebtop, "|||")
 
  If InStr(tmpstring, "|||" & NewWebTop & "|||") Or InStr(tmpstring, "|||" & NewWebTop) Or InStr(tmpstring, NewWebTop & "|||") = 1 Then
    
     oWebServer.serverbindings = tmpwebtop
    
      Else
    
     ReDim Preserve tmpwebtop(UBound(tmpwebtop) + 1)
    
     tmpwebtop(UBound(tmpwebtop)) = NewWebTop
  
     oWebServer.serverbindings = tmpwebtop
    
  End If
 
  oWebServer.SetInfo
 
  If Err.Number <> 0 Then Call ErrMessage("发生意外错误,请和管理员联系。")
 
  Err.Clear


End Function

'===============================================================
'函数名称:DelWebSiteHostName
'函数功能:在已存在的站点中主机头中删除一个主机头
'           index 站点编号
'          WebTop 主机头字符串
'开发成员:MMC(mmcgzs@hotmail.com)
'===============================================================
Public Function DelWebSiteHostName(index, WebTop)
 
  On Error Resume Next
 
  Dim tmpwebtop, ztop, oWebServer, tmpstring, Computer, i
 
  Computer = "localhost"
 
  Set oWebServer = GetObject("IIS://" & Computer & "/w3svc/" & index)
 
  tmpwebtop = oWebServer.serverbindings '''获取原来的主机头
  
  tmpstring = Join(tmpwebtop, "|||")
 
  If InStr(tmpstring, "|||" & WebTop & "|||") Or InStr(tmpstring, "|||" & WebTop) Or InStr(tmpstring, WebTop & "|||") = 1 Then
    
    
     For i = 0 To UBound(tmpwebtop)
                
       If i > UBound(tmpwebtop) Then Exit For
           
       If tmpwebtop(i) = WebTop Then
        
         tmpwebtop(i) = tmpwebtop(UBound(tmpwebtop))
 
         ReDim Preserve tmpwebtop(UBound(tmpwebtop) - 1)
 
       End If
       
     Next
    
     oWebServer.serverbindings = tmpwebtop
    
    
  End If
 
  oWebServer.SetInfo

  If Err.Number <> 0 Then Call ErrMessage("发生意外错误,请和管理员联系。")
 
  Err.Clear

End Function

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值