打印本文 打印本文 关闭窗口 关闭窗口
VB.NET下通过WMI共享文件夹
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3526  更新时间:2009/4/23 19:00:36  文章录入:mintao  责任编辑:mintao
bsp;   Get
                Return _share.GetPropertyValue("Status").ToString
            End Get
        End Property

        '''''''''''' -----------------------------------------------------------------------------
        '''''''''''' <summary>
        '''''''''''' Gets the share type.
        '''''''''''' </summary>
        '''''''''''' <history>
        '''''''''''' [Eduardo Morcillo] 11/08/2004 Created
        '''''''''''' </history>
        '''''''''''' -----------------------------------------------------------------------------
        Public ReadOnly Property Type() As ShareType
            Get

                Dim typeValue64 As Long = Convert.ToInt64(_share.GetPropertyValue("Type"), CultureInfo.InvariantCulture)
                Dim typeValue32 As Integer

                If (typeValue64 And &H80000000) > 0 Then
                    typeValue32 = &H80000000 Or Convert.ToInt32(typeValue64 And &H7FFFFFFF, CultureInfo.InvariantCulture)
                Else
                    typeValue32 = Convert.ToInt32(typeValue64, CultureInfo.InvariantCulture)
                End If

                Return CType(typeValue32, ShareType)

            End Get
        End Property

        '''''''''''' -----------------------------------------------------------------------------
        '''''''''''' <summary>
        '''''''''''' Creates a shared folder in the local computer.
        '''''''''''' </summary>
        '''''''''''' <history>
        '''''''''''' [Eduardo Morcillo] 11/08/2004 Created
        '''''''''''' </history>
        '''''''''''' -----------------------------------------------------------------------------
        Public Shared Function Create( _
                    ByVal path As String, _
                    ByVal name As String) As NetShare

            Return Create(".", path, ShareType.DiskDrive, name, -1, Nothing, Nothing)

        End Function

        '''''''''''' -----------------------------------------------------------------------------
        '''''''''''' <summary>
        '''''''''''' Creates a shared folder in the local computer.
        '''''''''''' </summary>
        '''''''''''' <history>
        '''''''''''' [Eduardo Morcillo] 11/08/2004 Created
        '''''''''''' </history>
        '''''''''''' -----------------------------------------------------------------------------
        Public Shared Function Create( _
                    ByVal path As String, _
                    ByVal name As String, _
                    ByVal password As String) As NetShare

            Return Create(".", path, ShareType.DiskDrive, name, -1, Nothing, password)

        End Function

        '''''''''''' -----------------------------------------------------------------------------
        '''''''''''' <summary>
        '''''''''''' Creates a shared folder in the local computer.
        '''''''''''' </summary>
        '''''''''''' <history>
        '''''''''''' [Eduardo Morcillo] 11/08/2004 Created
        '''''''''''' </history>
        '''''''''''' -----------------------------------------------------------------------------
        Public Shared Function Create( _
                    ByVal path As String, _
                    ByVal type As ShareType, _
                    ByVal name As String, _
                    ByVal maximumAllowed As Integer, _
                    ByVal description As String, _
                    ByVal password As String) As NetShare

            Return Create(".", path, type, name, maximumAllowed, description, password)

        End Function

        '''''''''''' -----------------------------------------------------------------------------
        '''''''''''' <summary>
        '''''''''''' Creates a shared resource in the specified computer.
        '''''''''''' </summary>
        '''''''''''' <history>
        '''''''''''' [Eduardo Morcillo] 11/08/2004 Created
        '''''''''''' </history>
        '''''''''''' -----------------------------------------------------------------------------
        Public Shared Function Create( _
            ByVal computerName As String, _
            ByVal path As String, _
            ByVal type As ShareType, _
            ByVal name As String, _
            ByVal maximumAllowed As Integer, _
            ByVal description As String, _
            ByVal password As String) As NetShare

            Dim shareClass As New System.Management.ManagementClass(String.Format("\\{0}\root\cimv2:Win32_Share", computerName))
            Dim res As Integer

            Try

                If maximumAllowed < 0 Then

                    res = Convert.ToInt32( _
                        shareClass.InvokeMethod("Create", _
                        New Object() {path, name, type, Nothing,

上一页  [1] [2] [3] [4]  下一页

打印本文 打印本文 关闭窗口 关闭窗口