Fritz Posted September 18, 2004 Posted September 18, 2004 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 Quote
Mykre Posted September 27, 2004 Posted September 27, 2004 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. Quote Glenn "Mykre" Wilson, DirectX MVP Inner Realm Managed DirectX and Game Programming Resources
Fritz Posted September 27, 2004 Author Posted September 27, 2004 >> 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. Quote
Mykre Posted September 27, 2004 Posted September 27, 2004 >> 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 Quote Glenn "Mykre" Wilson, DirectX MVP Inner Realm Managed DirectX and Game Programming Resources
Fritz Posted September 27, 2004 Author Posted September 27, 2004 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.