Common IIS Operation Programming implementation (VB6)

Source: Internet
Author: User

I didn't know it before, and I still couldn't find relevant information on the Internet. Later I accidentally saw the relevant content in a delphi introduction, so I used vb as an imitation.
If some people accidentally see the benefits, they are very pleased.
Basic: Add the following references: 1, iisext. dll; 2, adsiis. dll; 3, activeds. tlb.
1. Create a virtual directory in IIS,
Dim sComputer as string
Dim websvc, vRoot, vDir
SComputer = "localhost"

'Get Default Web Site Object
Set websvc = GetObject ("IIS: //" & sComputer & "/W3svc/1 ")

'Get root of Default Web Site
Set vRoot = websvc. GetObject ("IIsWebVirtualDir", "Root ")

Dim itm As ListItem
Dim buf As String, errInfo As String, tryVirt
For Each itm In ListView1.ListItems
Err. Clear
On Error Resume Next
Set tryVirt = GetObject ("IIS: //" & sComputer & "/W3svc/1/ROOT/" & itm. SubItems (1 ))
'Debug. Print Err. Number
'If no virtual directory is available, an error occurs. You can create a new virtual directory.
If Err. Number <> 0 Then
Err. Clear
Set vDir = vRoot. Create ("IISWebVirtualDir", itm. SubItems (1 ))
VDir. path = itm. Text
VDir. Accessread = True
VDir. SetInfo
Else
'Record The Name Of The created virtual directory.
'If tryVirt. AppGetStatus2 = 0 Then
ErrInfo = errInfo & vbCrLf & itm. SubItems (1)
End If

Next
Actually
Set websvc = GetObject ("IIS: //" & sComputer & "/W3svc/1 ")
Set vRoot = websvc. GetObject ("IIsWebVirtualDir", "Root ")
Set vDir = vRoot. Create ("IISWebVirtualDir", vdName)
VDir. Path = someDir
VDir. setInfo
These statements are enough.
2. Delete virtual directory
Dim sComputer, sPhyDir, sVirDir As String

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.