public static void Set1005Flags(string serverName, string name, SHI1005_FLAGS flags)
    {
        // note: you need to have enough rights to call this
        int err = NetShareSetInfo(serverName, name, 1005, ref flags, IntPtr.Zero);

        if (err != 0)
        {
            throw new Win32Exception(err);
        }
    }
 private extern static int NetShareSetInfo([MarshalAs(UnmanagedType.LPWStr)] string servername, [MarshalAs(UnmanagedType.LPWStr)] string netname, int level, ref SHI1005_FLAGS buf, IntPtr parm_err);