Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am creating a share for my app-folder:

 

 

Imports System.Management

 

On BTN_CLICK:

 

Dim apath As String = IO.Directory.GetCurrentDirectory()

 

'Const IsFileShare As Integer = 0

'Const Max_Connections As Integer = 10

Dim Share_Info As String() = {apath, "MyApp", 0}

Dim Win_Shares As ManagementClass = New ManagementClass("Win32_Share")

Try

Win_Shares.InvokeMethod("Create", Share_Info)

Catch ex As System.Management.ManagementException

MessageBox.Show(ex.ToString)

Return

Finally

Win_Shares.Dispose()

End Try

MessageBox.Show("Share: " + Share_Info(0) + " succeed!")

 

This works fine for W2000/XP. It also creates a share on Win98/Me, but ReadOnly. And of course like that the App will not run on client machines.

 

I have also tried with API's, all kind of stuff, also with VB6 code, but the code above still works best, except for this silly little detail, and I cannot find a way to change the ReadOnly-mode to ReadWrite.

 

Anybody got an idea?

 

Fritz

  • 2 weeks later...
Posted
I am creating a share for my app-folder:

 

 

Imports System.Management

 

On BTN_CLICK:

 

Dim apath As String = IO.Directory.GetCurrentDirectory()

 

'Const IsFileShare As Integer = 0

'Const Max_Connections As Integer = 10

Dim Share_Info As String() = {apath, "MyApp", 0}

Dim Win_Shares As ManagementClass = New ManagementClass("Win32_Share")

Try

Win_Shares.InvokeMethod("Create", Share_Info)

Catch ex As System.Management.ManagementException

MessageBox.Show(ex.ToString)

Return

Finally

Win_Shares.Dispose()

End Try

MessageBox.Show("Share: " + Share_Info(0) + " succeed!")

 

This works fine for W2000/XP. It also creates a share on Win98/Me, but ReadOnly. And of course like that the App will not run on client machines.

 

I have also tried with API's, all kind of stuff, also with VB6 code, but the code above still works best, except for this silly little detail, and I cannot find a way to change the ReadOnly-mode to ReadWrite.

 

Anybody got an idea?

 

Fritz

 

It might have something to do with the ACL. Try forceing the permissions on the creation of the share.

Glenn "Mykre" Wilson, DirectX MVP

Inner Realm

Managed DirectX and Game Programming Resources

Posted

>> It might have something to do with the ACL. Try forceing the permissions on the creation of the share.

 

Yes, of course, I think it has to do with the ACL. But I find no way to force it under W98. If I use API, there are 3 different structures:

 

shi_2 - for W2000/XP

shi_502 - for NT/2000/XP

shi_50 - for W95/98/Me

 

And the shi_50 just seems to have no entry for ACL or security descriptor. I simply don't know enough about these declarations and the help stuff also is only confusing me.

 

As I said: the WMI above at least does everything right for W2000/XP (and NT too I think). And in W98/Me it creates the share, but ReadOnly.

 

I am trying a workaround now, calling the file properties dialog, so the user can at least set the share without having to search the file first. That works but it's not really a fine way.

Posted
>> It might have something to do with the ACL. Try forceing the permissions on the creation of the share.

 

Yes, of course, I think it has to do with the ACL. But I find no way to force it under W98. If I use API, there are 3 different structures:

 

shi_2 - for W2000/XP

shi_502 - for NT/2000/XP

shi_50 - for W95/98/Me

 

And the shi_50 just seems to have no entry for ACL or security descriptor. I simply don't know enough about these declarations and the help stuff also is only confusing me.

 

As I said: the WMI above at least does everything right for W2000/XP (and NT too I think). And in W98/Me it creates the share, but ReadOnly.

 

I am trying a workaround now, calling the file properties dialog, so the user can at least set the share without having to search the file first. That works but it's not really a fine way.

 

Try these links

 

Reading Share information

 

http://www.codeproject.com/csharp/networkshares.asp

 

Creating a FileShare

 

http://www.codeproject.com/dotnet/pinvokeaddshare.asp

Glenn "Mykre" Wilson, DirectX MVP

Inner Realm

Managed DirectX and Game Programming Resources

Posted
I have already seen these articles. This works all with the netapi32.dll and the shi_502. But W98/Me only accept svrapi.dll and the shi_50. Also in W2000/XP there is no need to declare ReadWrite permissions because any share is ReadWrite. The Items concerning permissions only handle with passwords and that's not the problem.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...