因为我要在IIS上配置PHP,
必须要在网站的--属性---主目录---配置---映射 上新建一个PHP文件的映射
指向C:\PHP\PHP5ISAPI.DLL由于工作量较大
我就在写一个工具,让IIS自动配置上去
但是不知道用VB怎么添加一个ISAPI映射?

解决方案 »

  1.   

    用VC来做吧:http://dev.21tx.com/2005/03/14/13316.html
      

  2.   

    只是要在iis里面添加一个映射吗?
    建议你看看Inetpub\AdminScripts\下面的vbs,可能有你需要的~
      

  3.   

    没找到合适的函数哦
    我就是要用VB来做
    C不太熟悉
      

  4.   

    认知上,你这个文件C:\PHP\PHP5ISAPI.DLL是需要按照1楼给的那种方法来做~ 当然,也可以封装成dll,vb来调用至于只是 要把*.PHP映射到PHP5ISAPI.DLL上去,应该是手动添加的,这也是你要编码解决的问题,是吗?vb的Active Directory对象应该能解决这个问题~  
    .net的System.DirectoryServices命名空间~
    公司机器上iis被锁掉了,没办法帮你写代码和调试~ 给一段代码给你参考~ 看你自己能不能找到所需要的资料~照着System.DirectoryServices查msdn吧,多试试应该能做到~
    Imports System.DirectoryServices
    Class form1
        Private Sub CreateVirtualDir(ByVal WebSite As String, ByVal AppName As String, ByVal Path As String)
            Dim IISSchema As New System.DirectoryServices.DirectoryEntry("IIS://" & WebSite & "/Schema/AppIsolated")
            Dim CanCreate As Boolean = Not IISSchema.Properties("Syntax").Value.ToString.ToUpper() = "BOOLEAN"
            IISSchema.Dispose()
            If CanCreate Then
                Dim PathCreated As Boolean
                Try                Dim IISAdmin As New System.DirectoryServices.DirectoryEntry("IIS://" & WebSite & "/W3SVC/1/Root")
                    'make sure folder exists                
                    If Not System.IO.Directory.Exists(Path) Then
                        System.IO.Directory.CreateDirectory(Path)
                        PathCreated = True
                    End If
                    'If the virtual directory already exists then delete it      
                    For Each VD As System.DirectoryServices.DirectoryEntry In IISAdmin.Children                    If VD.Name = AppName Then
                            IISAdmin.Invoke("Delete", New String() {VD.SchemaClassName, AppName})
                            IISAdmin.CommitChanges()
                            Exit For
                        End If
                    Next VD                 'Create and setup new virtual directory                
                    Dim VDir As System.DirectoryServices.DirectoryEntry = IISAdmin.Children.Add(AppName, "IIsWebVirtualDir")
                    VDir.Properties("Path").Item(0) = Path
                    VDir.Properties("AppFriendlyName").Item(0) = AppName
                    VDir.Properties("EnableDirBrowsing").Item(0) = False
                    VDir.Properties("AccessRead").Item(0) = True
                    VDir.Properties("AccessExecute").Item(0) = True
                    VDir.Properties("AccessWrite").Item(0) = False
                    VDir.Properties("AccessScript").Item(0) = True
                    VDir.Properties("AuthNTLM").Item(0) = True
                    VDir.Properties("EnableDefaultDoc").Item(0) = True
                    VDir.Properties("DefaultDoc").Item(0) = "default.htm,default.aspx,default.asp"
                    VDir.Properties("AspEnableParentPaths").Item(0) = True
                    VDir.CommitChanges()
                    'the following are acceptable params                
                    'INPROC = 0              'OUTPROC = 1               'POOLED = 2                
                    VDir.Invoke("AppCreate", 1)
                Catch Ex As Exception
                    If PathCreated Then                    System.IO.Directory.Delete(Path)
                    End If
                    Throw Ex
                End Try
            End If
        End Sub
    End Class
      

  5.   

    有本这样的书:
    《Programming with ISAPI with Visual Basic 5》
    你看看电驴上面有没有下载的。但是我强烈建议不要使用VB来做这样的事情。
      

  6.   

    不知道楼主是不是要这个~
    http://blog.csdn.net/lessoft/archive/2007/08/30/1765695.aspx  delphi的
      

  7.   

    http://msdn.microsoft.com/en-us/library/ms524997(VS.85).aspx  IIS ADSI Provider
      

  8.   

    vb的 给你写了一个 自己再调试调试~Private Function AddISAPIFilterToIISGlobal(FilterName As String, FilterPath As String, FilterDesc As String) As Boolean
        Dim IISNamespace
        Set IISNamespace = CreateObject("IISNamespace")
        Dim IISWebService
        Set IISWebService = IISNamespace.GetObject("IIsWebService", "localhost/w3svc")
        Dim IISFilters
        Set IISFilters = IISWebService.GetObject("IISFilters", "Filters")
          If IsNull(IISFilters) Or IsEmpty(IISFilters) Then
                  Set IISFilters = web_server.Create("IIsFilters", "Filters")
          End If
        Set IIsFilter = IISFilters.Create("IIsFilter", FilterName)
        IIsFilter.FilterPath = FilterPath
        IIsFilter.FilterDescription = FilterDesc
        IIsFilter.SetInfoEnd Function