Click here to Skip to main content
15,908,173 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionHow do you add code snippets Pin
directred20-Apr-07 1:25
directred20-Apr-07 1:25 
AnswerRe: How do you add code snippets Pin
Dave Kreskowiak20-Apr-07 4:28
mveDave Kreskowiak20-Apr-07 4:28 
QuestionUPLOADING IMAGE USING OPEN FILE DIALOG Pin
klaydze19-Apr-07 22:10
klaydze19-Apr-07 22:10 
AnswerRe: UPLOADING IMAGE USING OPEN FILE DIALOG Pin
Christian Graus19-Apr-07 23:52
protectorChristian Graus19-Apr-07 23:52 
GeneralRe: UPLOADING IMAGE USING OPEN FILE DIALOG Pin
klaydze20-Apr-07 15:46
klaydze20-Apr-07 15:46 
QuestionDirectory share and fileshare problem [modified] Pin
battulga19-Apr-07 21:56
battulga19-Apr-07 21:56 
AnswerRe: Directory share and fileshare problem Pin
Dave Kreskowiak20-Apr-07 3:43
mveDave Kreskowiak20-Apr-07 3:43 
GeneralRe: Directory share and fileshare problem Pin
battulga20-Apr-07 21:05
battulga20-Apr-07 21:05 
i tried to open the folder from another machine using correct path which was "\\server\foldersharename".

i'm trying to share a folder by another way. code here: >>

Sub MyShare()<br />
        Dim serverName, UserName, AdminName, UserAcct As String<br />
        Dim Ace1 As Management.ManagementObject<br />
        serverName = SystemInformation.ComputerName<br />
        Dim scope As New ManagementScope("\\" + SystemInformation.ComputerName + "\root\cimv2")<br />
        Dim wmiShare As New Management.ManagementClass(scope, New Management.ManagementPath("Win32_Share"), Nothing)<br />
        UserName = SystemInformation.UserName<br />
<br />
        Dim userAccount As ManagementObject<br />
        Dim userExists As Boolean = False<br />
        Dim userSearcher As New ManagementObjectSearcher(scope, New SelectQuery(String.Format("SELECT * from Win32_UserAccount WHERE domain='{0}'", serverName))) <br />
        For Each userAccount In userSearcher.Get()<br />
            If (String.Compare(UserName, userAccount("Name"), True) = 0) Then<br />
                userExists = True<br />
                Exit For<br />
            End If<br />
        Next<br />
        if not userExists then<br />
            Msgbox("User not found")<br />
            Exit Sub<br />
        End if<br />
<br />
        Ace1 = SetAce(scope, 2032127, 3, 0, SetTrustee(scope, serverName, UserName, GetBinarySid(scope, userAccount("sid")))) '<br />
<br />
        Dim secDescriptor As Management.ManagementObject<br />
        secDescriptor = New Management.ManagementClass(scope, New Management.ManagementPath("Win32_SecurityDescriptor"), Nothing).CreateInstance()<br />
        secDescriptor("ControlFlags") = 4<br />
        secDescriptor("DACL") = New Management.ManagementObject() {Ace1}<br />
<br />
        Dim inParams As Management.ManagementBaseObject<br />
        inParams = wmiShare.GetMethodParameters("Create")<br />
        inParams("Access") = secDescriptor<br />
        inParams("Path") = "C:\new folder"<br />
        inParams("Name") = "foldersharename"<br />
        inParams("Type") = 0<br />
        inParams("MaximumAllowed") = 5<br />
        inParams("Description") = "FolderDescriptionHere"<br />
        Dim outParams As Management.ManagementBaseObject<br />
<br />
        outParams = wmiShare.InvokeMethod("Create", inParams, Nothing)<br />
        MsgBox("Successful")<br />
    End Sub<br />
<br />
Function GetBinarySid(ByVal scope As ManagementScope, ByVal sid As String)As Byte() <br />
        Dim wmiSid As New ManagementObject(scope, New ManagementPath(String.Format("Win32_SID.SID='{0}'", sid)), Nothing)<br />
        Return wmiSid("BinaryRepresentation")<br />
    End Function<br />
<br />
    Function SetTrustee(ByVal scope As Management.ManagementScope, ByVal domain As String, ByVal name As String, ByVal UserSid As Byte()) As Management.ManagementObject<br />
        Dim wmiTrustee As Management.ManagementObject<br />
        wmiTrustee = New Management.ManagementClass(scope, New Management.ManagementPath("Win32_Trustee"), Nothing).CreateInstance()<br />
        wmiTrustee("Domain") = domain<br />
        wmiTrustee("Name") = name<br />
        wmiTrustee("SID") = UserSid<br />
        Return wmiTrustee<br />
    End Function<br />
<br />
    Function SetAce(ByVal scope As Management.ManagementScope, ByVal accessMask As Integer, ByVal aceFlags As Integer, ByVal aceType As Integer, ByVal wmiTrustee As Management.ManagementObject) As Management.ManagementObject<br />
        Dim wmiAce As Management.ManagementObject<br />
        wmiAce = New Management.ManagementClass(scope, New Management.ManagementPath("Win32_ACE"), Nothing).CreateInstance()<br />
        wmiAce("AccessMask") = accessMask<br />
        wmiAce("AceFlags") = aceFlags<br />
        wmiAce("AceType") = aceType<br />
        wmiAce("Trustee") = wmiTrustee<br />
        Return wmiAce<br />
    End Function


But steel that message appeared. When I tried to open the folder from Windows Explorer from other machines, message appears again. My user is of Administrator group and has no password. When I share a folder manually from Explorer, all is fine. What is wrong with me?
GeneralRe: Directory share and fileshare problem Pin
Craster23-Apr-07 5:06
Craster23-Apr-07 5:06 
QuestionResize Image Pin
nitin_ion19-Apr-07 19:53
nitin_ion19-Apr-07 19:53 
AnswerRe: Resize Image Pin
Christian Graus19-Apr-07 19:59
protectorChristian Graus19-Apr-07 19:59 
GeneralRe: Resize Image Pin
nitin_ion21-Apr-07 21:02
nitin_ion21-Apr-07 21:02 
GeneralRe: Resize Image Pin
Christian Graus21-Apr-07 23:53
protectorChristian Graus21-Apr-07 23:53 
GeneralRe: Resize Image Pin
TwoFaced22-Apr-07 7:04
TwoFaced22-Apr-07 7:04 
GeneralRe: Resize Image Pin
Christian Graus22-Apr-07 12:09
protectorChristian Graus22-Apr-07 12:09 
QuestionComplex Calculator Pin
Aptiva Dave19-Apr-07 17:29
Aptiva Dave19-Apr-07 17:29 
AnswerRe: Complex Calculator Pin
The ANZAC19-Apr-07 19:11
The ANZAC19-Apr-07 19:11 
AnswerRe: Complex Calculator Pin
The ANZAC20-Apr-07 0:53
The ANZAC20-Apr-07 0:53 
GeneralRe: Complex Calculator Pin
Aptiva Dave20-Apr-07 14:51
Aptiva Dave20-Apr-07 14:51 
GeneralRe: Complex Calculator Pin
Aptiva Dave21-Apr-07 18:36
Aptiva Dave21-Apr-07 18:36 
QuestionRowChanged DataTable Event proplme Pin
ora-dbaabode19-Apr-07 13:38
ora-dbaabode19-Apr-07 13:38 
AnswerRe: RowChanged DataTable Event proplme Pin
Polymorpher19-Apr-07 16:25
Polymorpher19-Apr-07 16:25 
QuestionDLL Initialization Pin
Polymorpher19-Apr-07 12:16
Polymorpher19-Apr-07 12:16 
AnswerRe: DLL Initialization Pin
Dave Kreskowiak19-Apr-07 14:50
mveDave Kreskowiak19-Apr-07 14:50 
GeneralRe: DLL Initialization Pin
Polymorpher19-Apr-07 16:20
Polymorpher19-Apr-07 16:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.