895 views(since 2013/10/08)

ファイル権限デザイナーで使用しているNet系APIについての解説

はじめに

ファイル権限デザイナーはC#で作成されていますが、ファイル権限の操作のところ .NETのライブラリーだけでは難しいので、重要な機能はAPIで作成されております。その一例を紹介します。

今回はNetAPI系を説明します。

ユーザを追加するときに、ユーザ一覧が必要ですが、まず、対象のファイルを管理している、PCがドメインコントローラか、スタンドアローンサーバか、ワークステーションか判断する必要があります。それにより、ドメインコントローラからユーザ一覧を取得したり、サーバローカルのユーザからユーザ一覧を取得したり制御しています。

ファイル権限デザイナーで使用しているNetAPIの一部

//NetUserChangePassword ユーザーのパスワードを変更 
//NetUserGetGroups ユーザーが属しているグローバルグループのリストを取得 
//NetUserGetInfo ユーザーアカウントに関する情報を取得 
//NetUserGetLocalGroups ユーザーが属しているローカルグループのリストを取得 
//NetUserSetGroups アカウントに対するグローバルなグループメンバの資格を設定 
//NetUserSetInfo ユーザーアカウントのパラメータを設定 
//NetUserModalsGet すべてのユーザーとグローバルなグループのグローバルな情報を取得 
//NetUserModalsSet すべてのユーザーとグローバルなグループのグローバルな情報を設定 

//NetLocalGroupAdd ローカルグループを作成 
//NetLocalGroupAddMembers ローカルグループに既存のアカウントまたはグローバルグループのメンバの資格を与える 
//NetLocalGroupDel ローカルグループアカウントとそのすべてのメンバを削除 
//NetLocalGroupDelMembers 特定のローカルグループからメンバを削除 
//NetLocalGroupEnum ローカルグループアカウントに関する情報を取得 //NetLocalGroupGetInfo サーバー上の特定のローカルグループアカウントに関する情報を取得 
//NetLocalGroupSetInfo ローカルグループアカウントのパラメータを設定 

//NetShareAdd
//NetShareDel
//NetShareEnum
//NetShareGetInfo
//NetShareSetInfo

using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;

using System.Collections;
using System.Collections.Generic;

namespace Cadree.Common.Object
{
    public class CaD_API_NetApi32
    {
        //--------------------------------------------------------------------------------------------------------------------
        // GetServerNameFromFQN
        //--------------------------------------------------------------------------------------------------------------------
        static private STRUCT_strServerName_Original GetServerNameFromFQN(string strFQN)
        {
            STRUCT_strServerName_Original strServerName_Original;
            strServerName_Original.value = "";
            if (strFQN != "")
            {
                if (strFQN.Substring(0, CAD_String.YENYEN.Length) == CAD_String.YENYEN)
                {
                    int nPos = strFQN.IndexOf(CAD_String.YEN, CAD_String.YENYEN.Length);
                    if (nPos == -1)
                    {
                        strServerName_Original.value = strFQN.Substring(CAD_String.YENYEN.Length);
                    }
                    else
                    {
                        strServerName_Original.value = strFQN.Substring(CAD_String.YENYEN.Length, nPos - CAD_String.YENYEN.Length);
                    }
                }
            }
            return strServerName_Original;
        }

        //---------------------------------------------------------------------------------------------------------------
        // IsThisPC_FullPath
        //---------------------------------------------------------------------------------------------------------------
        static public bool IsThisPC_FullPath(string strFullPath)
        {
            STRUCT_strServerName_Original  strServerName_Original = GetServerNameFromFullPah(strFullPath);
            if (String.Compare(strServerName_Original.value, CaD_Directory.GetThisPC_Machine_ShortName().value, true) == 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        //---------------------------------------------------------------------------------------------------------------
        // GetNetSharePath
        //---------------------------------------------------------------------------------------------------------------
        public struct STRUCT_NetSharePath
        {
            public STRUCT_strServerName_Original strServerName_Original;
            public string strNetFullPath;
            public string strNetPath;
            public string strNetName;
        }

        public static STRUCT_NetSharePath GetNetSharePath(string strFullPath)
        {

            STRUCT_NetSharePath NetSharePath;

            {

                int nPos = strFullPath.IndexOf(CAD_String.CORON);
                if (nPos == -1)
                {
                    //ネットワーク名
                    int nPosYen = strFullPath.IndexOf(CAD_String.YEN, CAD_String.YENYEN.Length);
                    int nPosYenNext = strFullPath.IndexOf(CAD_String.YEN, nPosYen + CAD_String.YEN.Length);

                    if (nPosYenNext == -1)
                    {
                        //ここ絶対こないかもしれない。わからないのでおいておく。
                        NetSharePath.strNetPath = strFullPath;
                    }
                    else
                    {
                        NetSharePath.strNetPath = strFullPath.Substring(0, nPosYenNext);
                    }
                    //NetSharePath.strNetFullPath
                    NetSharePath.strNetFullPath = strFullPath;
                    //--------------------------------------------

                }
                else
                {
                    //ローカルドライブ
                    string strDriveName = strFullPath.Substring(0, nPos + 1);
                    string strFQN = CaD_API_Mpr.GetConnetctionFromDriveName(strDriveName);
                    if (strFQN == "")
                    {
                        //throw new Exception("GetNetSharePath; ローカルドライブなのに、この関数がよびだされました。");
                        NetSharePath.strNetPath = strDriveName; //ネットワークドライブでない。
                    }
                    else
                    {
                        NetSharePath.strNetPath = strFQN;
                    }

                    //NetSharePath.strNetFullPath
                    if (strFullPath.Length > (nPos + CAD_String.YEN.Length + 1))
                    {
                        NetSharePath.strNetFullPath = NetSharePath.strNetPath + CAD_String.YEN + strFullPath.Substring(nPos + CAD_String.YEN.Length + 1);
                    }
                    else
                    {
                        NetSharePath.strNetFullPath = NetSharePath.strNetPath;
                    }
                    //--------------------------------------------

                }

                //NetSharePath.strNetFullPath------------------
                //最後の\を削除する。(フォルダーはつけたらいいかもしれんが、とりあえず。下の関数IsRootShareFolderしかつかっていないのであんまりかんがえないではずしておく)
                //将来ほかでNetSharePath.strNetFullPathを使う場合にかんがえればよい。
                if (NetSharePath.strNetFullPath.Substring(NetSharePath.strNetFullPath.Length - 1) == CAD_String.YEN)
                {
                    NetSharePath.strNetFullPath = NetSharePath.strNetFullPath.Substring(0, NetSharePath.strNetFullPath.Length - 1);
                }
                //--------------------------------------------
            }

            {
                int nPos = NetSharePath.strNetPath.IndexOf(CAD_String.YEN, CAD_String.YENYEN.Length);
                NetSharePath.strNetName = NetSharePath.strNetPath.Substring(nPos + CAD_String.YEN.Length);
            }

            {
                NetSharePath.strServerName_Original.value = CaD_API_NetApi32.GetServerNameFromFullPah(strFullPath).value;
            }

            return NetSharePath;

        }

        //---------------------------------------------------------------------------------------------------------------
        // IsRootShareFolder 
        //---------------------------------------------------------------------------------------------------------------
        public static bool IsRootShareFolder(bool IsDirectory, string strFullPath)
        {
            if (IsDirectory)
            {
                CaD_API_NetApi32.STRUCT_NetSharePath NetSharePath = CaD_API_NetApi32.GetNetSharePath(strFullPath);

                if (NetSharePath.strNetFullPath.StartsWith(CAD_String.YENYEN))
                {
                    int nPos = NetSharePath.strNetFullPath.IndexOf(CAD_String.YEN, CAD_String.YENYEN.Length);
                    if (nPos == -1)
                    {
                        throw new Exception("Error; IsShareRoot; ありえない処理です。");
                    }

                    nPos = NetSharePath.strNetFullPath.IndexOf(CAD_String.YEN, nPos + 1);
                    if (nPos == -1)
                    {
                        //ルートです。
                        return true;
                    }
                }
            }
            return false;
        }

        //---------------------------------------------------------------------------------------------------------------
        // GetServerNameFromFullPah
        //---------------------------------------------------------------------------------------------------------------
        static public STRUCT_strServerName_Original GetServerNameFromFullPah(string strFullPath)
        {
            STRUCT_strServerName_Original strServerName_Original;
            strServerName_Original.value = "";

            int nPos = strFullPath.IndexOf(CAD_String.CORON);

            if (nPos == -1)
            {
                //ネットワーク名
                strServerName_Original = GetServerNameFromFQN(strFullPath);
            }
            else
            {
                //ローカルドライブ
                string strDriveName = strFullPath.Substring(0, nPos + 1);
                string strFQN = CaD_API_Mpr.GetConnetctionFromDriveName(strDriveName);
                if (strFQN == "")
                {
                    strServerName_Original.value = CaD_Directory.GetThisPC_Machine_ShortName().value;
                }
                else
                {
                    strServerName_Original = GetServerNameFromFQN(strFQN);
                }
            }
            return strServerName_Original;
        }

        //--------------------------------------------------------------------------------------------------------------------
        // IsDomainControler
        //--------------------------------------------------------------------------------------------------------------------
        static public bool IsDomainControler(STRUCT_strServerName_Original strServerName_Original)
        {
            SERVER_INFO_101 serverInfo = GetServerInfo(strServerName_Original);

            if (
                   (((ServerType_Flags)serverInfo.Type & ServerType_Flags.SV_TYPE_DOMAIN_CTRL) == ServerType_Flags.SV_TYPE_DOMAIN_CTRL)
                   ||
                   (((ServerType_Flags)serverInfo.Type & ServerType_Flags.SV_TYPE_DOMAIN_BAKCTRL) == ServerType_Flags.SV_TYPE_DOMAIN_BAKCTRL)
               )
            {
                return true;
            }
            else
            {
                return false;
            }

        }

        //--------------------------------------------------------------------------------------------------------------------
        // GetServerName_FixBuiltIn
        //--------------------------------------------------------------------------------------------------------------------
        static Hashtable m_htServerName_FixBuiltIn = null;

        static public STRUCT_strServerName_FixBuiltIn GetServerName_FixBuiltIn(STRUCT_strServerName_Original strServerName_Original)
        {
            if (m_htServerName_FixBuiltIn == null)
            {
                m_htServerName_FixBuiltIn = new Hashtable();
            }

            if (m_htServerName_FixBuiltIn.ContainsKey(strServerName_Original.value))
            {
                return (STRUCT_strServerName_FixBuiltIn)m_htServerName_FixBuiltIn[strServerName_Original.value];
            }

            STRUCT_strServerName_FixBuiltIn strServerName_FixBuiltIn;
            strServerName_FixBuiltIn.value = strServerName_Original.value;

            if (IsDomainControler(strServerName_Original))
            {
                //ドメインコントローラなら(PDC,BDC)
                DOMAIN_INFO domainInfo = GetDomainInfo(strServerName_Original.value);

                if (domainInfo.netJoinStatus == NetJoinStatus.NetSetupDomainName)
                {
                    strServerName_FixBuiltIn.value = domainInfo.strDomainOrWorkgroupName;
                }
                else if (domainInfo.netJoinStatus == NetJoinStatus.NetSetupWorkgroupName)
                {
                    //ドメインサーバに対して「ドメインに参加していないPC」か「ローカルログイン」した場合にここにくる。
                    //なにもしない
                }
            }
            else
            {
                //なにもしない
            }

            m_htServerName_FixBuiltIn[strServerName_Original.value] = strServerName_FixBuiltIn;
            return strServerName_FixBuiltIn;

        }
        //--------------------------------------------------------------------------------------------------------------------
        // GetServerName_FixBuiltIn_FromFullPath
        //--------------------------------------------------------------------------------------------------------------------
        static public STRUCT_strServerName_FixBuiltIn GetServerName_FixBuiltIn_FromFullPath(string strFullPath)
        {

            STRUCT_strServerName_Original strServerName_Original = GetServerNameFromFullPah(strFullPath);

            return GetServerName_FixBuiltIn(strServerName_Original);

        }

//Common
        //--------------------------------------------------------------------------------------------------------------------
        // APISuccess
        //--------------------------------------------------------------------------------------------------------------------
        // Win32 Result Code Constant
        private const int APISuccess = 0;

        //--------------------------------------------------------------------------------------------------------------------
        // NetApiBufferFree
        //--------------------------------------------------------------------------------------------------------------------
        [DllImport("netapi32", CharSet = CharSet.Auto)]
        private static extern int NetApiBufferFree([In] IntPtr lpBuffer);

//NetServerGetInfo サーバのプラットフォームを判別PDC,BDC

        //--------------------------------------------------------------------------------------------------------------------
        // NetServerGetInfo
        //--------------------------------------------------------------------------------------------------------------------
        [DllImport("Netapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern int NetServerGetInfo(string serverName,int level,out IntPtr pSERVER_INFO_XXX);

        //--------------------------------------------------------------------------------------------------------------------
        // SERVER_INFO_101
        //--------------------------------------------------------------------------------------------------------------------
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
        public struct SERVER_INFO_101
        {
            public int PlatformId;
            [MarshalAs(UnmanagedType.LPTStr)]
            public string Name;
            public int VersionMajor;
            public int VersionMinor;
            public int Type;
            [MarshalAs(UnmanagedType.LPTStr)]
            public string Comment;
        }

        //--------------------------------------------------------------------------------------------------------------------
        // PlatformID
        //--------------------------------------------------------------------------------------------------------------------
        public enum PlatformID : uint
        {
            PLATFORM_ID_DOS = 300,
            PLATFORM_ID_OS2 = 400,
            PLATFORM_ID_NT = 500,
            PLATFORM_ID_OSF = 600,
            PLATFORM_ID_VMS = 700
        }
        //--------------------------------------------------------------------------------------------------------------------
        // ServerType
        //--------------------------------------------------------------------------------------------------------------------
        [Flags] //Flags 列挙体をビット・フィールドとして取り扱うには?http://www.atmarkit.co.jp/fdotnet/dotnettips/1052enumflags/enumflags.html
        public enum ServerType_Flags : uint
        {
            SV_TYPE_WORKSTATION = 0x00000001,   // すべてのワークステーション
            SV_TYPE_SERVER = 0x00000002,   // すべてのサーバー
            SV_TYPE_SQLSERVER = 0x00000004,   // すべてのMS SQL Server 
            SV_TYPE_DOMAIN_CTRL = 0x00000008,   // プライマリドメインコントローラ
            SV_TYPE_DOMAIN_BAKCTRL = 0x00000010,   // バックアップドメインコントローラ
            SV_TYPE_TIME_SOURCE = 0x00000020,   // Timesource サービスを実行しているサーバー
            SV_TYPE_AFP = 0x00000040,   // Apple File Protocol(AFP)サーバー
            SV_TYPE_NOVELL = 0x00000080,   // Novell サーバー
            SV_TYPE_DOMAIN_MEMBER = 0x00000100,   // LAN Manager 2.x のドメインメンバ
            SV_TYPE_PRINTQ_SERVER = 0x00000200,   // プリントキューを共有するサーバー
            SV_TYPE_DIALIN_SERVER = 0x00000400,   // ダイヤルインサービスを実行しているサーバー
            SV_TYPE_XENIX_SERVER = 0x00000800,   // Xenix サーバー
            SV_TYPE_SERVER_UNIX = SV_TYPE_XENIX_SERVER,   // 
            SV_TYPE_NT = 0x00001000,   // Windows NT/2000 のワークステーションまたはサーバー
            SV_TYPE_WFW = 0x00002000,   // Windows for Workgroups を実行しているサーバー
            SV_TYPE_SERVER_MFPN = 0x00004000,   // 
            SV_TYPE_SERVER_NT = 0x00008000,   // ドメインコントローラではない、Windows NT/2000 のサーバー
            SV_TYPE_POTENTIAL_BROWSER = 0x00010000,   // ブラウザサービスを実行できるサーバー
            SV_TYPE_BACKUP_BROWSER = 0x00020000,   // バックアップとしてブラウザサービスを実行しているサーバー
            SV_TYPE_MASTER_BROWSER = 0x00040000,   // マスタブラウザサービスを実行しているサーバー
            SV_TYPE_DOMAIN_MASTER = 0x00080000,   // ドメインマスタブラウザを実行しているサーバー
            SV_TYPE_SERVER_OSF = 0x00100000,   // 
            SV_TYPE_SERVER_VMS = 0x00200000,   // 
            SV_TYPE_WINDOWS = 0x00400000,   // Windows 95 以降
            SV_TYPE_DFS = 0x00800000,   // 
            SV_TYPE_CLUSTER_NT = 0x01000000,   // ドメイン内で利用できるサーバークラスタ
            SV_TYPE_TERMINALSERVER = 0x02000000,   // Terminal Server
            SV_TYPE_CLUSTER_VS_NT = 0x04000000,   // NT Cluster Virtual Server Name 
            SV_TYPE_DCE = 0x10000000,   // IBM DSS or equivalent 
            SV_TYPE_ALTERNATE_XPORT = 0x20000000,   // return list for alternate transport 
            SV_TYPE_LOCAL_LIST_ONLY = 0x40000000,   // Return local list only 
            SV_TYPE_DOMAIN_ENUM = 0x80000000,
            SV_TYPE_ALL = 0xFFFFFFFF    // すべてのサーバー
        }

        //--------------------------------------------------------------------------------------------------------------------
        // IsBeingServer
        //--------------------------------------------------------------------------------------------------------------------
        static public bool IsBeingServer(STRUCT_strServerName_Original strServerName_Original)
        {
            SERVER_INFO_101 serverInfo =  GetServerInfo(strServerName_Original);
            if (serverInfo.Type  != 0)
            {
                return true;
            }
            else
            {
                return false;
            }

        }

        //--------------------------------------------------------------------------------------------------------------------
        // GetServerInfo
        //--------------------------------------------------------------------------------------------------------------------
        static private SERVER_INFO_101 m_serverInfoOnError; //空
        private static Hashtable m_htServerInfo = null;

        //For Exsample         "SV001"        "192.168.20.16"
        static public SERVER_INFO_101 GetServerInfo(STRUCT_strServerName_Original strServerName_Original)
        {
            IntPtr pSI = IntPtr.Zero;
            try
            {
                if (m_htServerInfo == null)
                {
                    m_htServerInfo = new Hashtable();
                }

                if (m_htServerInfo.ContainsKey(strServerName_Original.value))
                {
                    return (SERVER_INFO_101)m_htServerInfo[strServerName_Original.value];
                }

                SERVER_INFO_101 serverInfo;
                if (NetServerGetInfo(strServerName_Original.value, 101, out pSI) == APISuccess)
                {
                    serverInfo = (SERVER_INFO_101)Marshal.PtrToStructure(pSI, typeof(SERVER_INFO_101));
                }
                else
                {
                    serverInfo =  m_serverInfoOnError;
                }

                m_htServerInfo[strServerName_Original.value] = serverInfo;
                return serverInfo;
            }
            finally
            {
                if (pSI != IntPtr.Zero) NetApiBufferFree(pSI);
            }
        }

//NetWkstaGetInfo  Workstation情報取得 (★使用しない。)

//        //--------------------------------------------------------------------------------------------------------------------
//        // WKSTA_INFO_100
//        //--------------------------------------------------------------------------------------------------------------------
//        [StructLayout(LayoutKind.Sequential, Pack = 4)]
//        struct WKSTA_INFO_100
//        {
//            public int wki100_platform_id;
//            public IntPtr wki100_computername;
//            public IntPtr wki100_langroup;
//            public int wki100_ver_major;
//            public int wki100_ver_minor;
//        }

//        //--------------------------------------------------------------------------------------------------------------------
//        // NetWkstaGetInfo
//        //--------------------------------------------------------------------------------------------------------------------
//        [DllImport("Netapi32.dll")]
//        private static extern int NetWkstaGetInfo(string servername, int level, out IntPtr bufptr);

//        //    NET_API_STATUS NetWkstaGetInfo(
//        //    LPWSTR servername,
//        //    DWORD level,
//        //    LPBYTE* bufptr
//        //    );

//        //--------------------------------------------------------------------------------------------------------------------
//        // GetWorkstationInfo
//        //--------------------------------------------------------------------------------------------------------------------
//        static private WKSTA_INFO_100 m_workstationInfoOnError; //空

//        static WKSTA_INFO_100 GetWorkstationInfo(string strWorkstationName)
//        {
//            IntPtr pWI = IntPtr.Zero;
//            WKSTA_INFO_100 workstationInfo;
//            workstationInfo.wki100_platform_id = 0; //なんかいれないとコンパイルエラーになる。

//            try
//            {
//                if (NetWkstaGetInfo(strWorkstationName, 100, out pWI) == APISuccess)
//                {
//                    return (WKSTA_INFO_100)Marshal.PtrToStructure(pWI, typeof(WKSTA_INFO_100));
//                }
//                else
//                {
//                    return m_workstationInfoOnError;
//                }
//            }
//            finally
//            {
//                if (pWI != IntPtr.Zero) NetApiBufferFree(pWI);
//            }
//        }

//NetGetJoinInformation ドメインかワークグループに参加しているのかを判別する。とドメイン名、ワークグループ名取得

        //--------------------------------------------------------------------------------------------------------------------
        // NetGetJoinInformation
        //--------------------------------------------------------------------------------------------------------------------
        [DllImport("Netapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern int NetGetJoinInformation(string server, out IntPtr domain, out NetJoinStatus status);

        //--------------------------------------------------------------------------------------------------------------------
        // NetJoinStatus
        //--------------------------------------------------------------------------------------------------------------------
        // NetGetJoinInformation() Enumeration
        public enum NetJoinStatus
        {
            NetSetupUnknownStatus = 0,
            NetSetupUnjoined,
            NetSetupWorkgroupName,
            NetSetupDomainName
        } // NETSETUP_JOIN_STATUS

        //--------------------------------------------------------------------------------------------------------------------
        // DOMAIN_INFO
        //--------------------------------------------------------------------------------------------------------------------
        public struct DOMAIN_INFO
        {
            public NetJoinStatus netJoinStatus;
            public string strDomainOrWorkgroupName;
        }

        //--------------------------------------------------------------------------------------------------------------------
        // GetDomainInfo
        //--------------------------------------------------------------------------------------------------------------------
        static private Hashtable htDomainInfo = null;

        public static DOMAIN_INFO  GetDomainInfo(string strWorkstationName)
        {
            if (htDomainInfo == null)
            {
                htDomainInfo = new Hashtable();
            }

            if (htDomainInfo.ContainsKey(strWorkstationName))
            {
                return (DOMAIN_INFO)htDomainInfo[strWorkstationName];
            }

            IntPtr pDomain = IntPtr.Zero;

            DOMAIN_INFO domainInfo;
            domainInfo.netJoinStatus = NetJoinStatus.NetSetupUnknownStatus;
            domainInfo.strDomainOrWorkgroupName= "";

            try
            {
                if (NetGetJoinInformation(strWorkstationName, out pDomain, out domainInfo.netJoinStatus) == APISuccess)
                {
                    if (domainInfo.netJoinStatus == NetJoinStatus.NetSetupDomainName || domainInfo.netJoinStatus == NetJoinStatus.NetSetupWorkgroupName)
                    {
                        domainInfo.strDomainOrWorkgroupName = Marshal.PtrToStringAuto(pDomain);
                    }
                }
                htDomainInfo[strWorkstationName] = domainInfo;

                return domainInfo;
            }
            finally
            {
                if (pDomain != IntPtr.Zero) NetApiBufferFree(pDomain);
            }
        }

        //---------------------------------------------------------------------------------------------------------------
        // IsJoinDomain_LocalMachine
        //---------------------------------------------------------------------------------------------------------------
        private static object objIsJoinDomain_ThisPC_Machine = null;

        public static bool IsJoinDomain_ThisPC_Machine
        {
            get
            {
                if (objIsJoinDomain_ThisPC_Machine == null)
                {
                    DOMAIN_INFO domain_info = GetDomainInfo(CaD_Directory.GetThisPC_Machine_ShortName().value);

                    objIsJoinDomain_ThisPC_Machine = domain_info.netJoinStatus == NetJoinStatus.NetSetupDomainName;

                }

                return (bool)objIsJoinDomain_ThisPC_Machine;

            }
        }

//NetUserGetGroups ローカルグループの取得
        //--------------------------------------------------------------------------------------------------------------------
        // NetLocalGroupGetMembers
        //--------------------------------------------------------------------------------------------------------------------
        [DllImport("NetAPI32.dll", CharSet = CharSet.Auto)]
        private extern static int NetLocalGroupGetMembers(
            [MarshalAs(UnmanagedType.LPWStr)] string servername,
            [MarshalAs(UnmanagedType.LPWStr)] string localgroupname,
            int level,
            out IntPtr bufptr,
            int prefmaxlen,
            out int entriesread,
            out int totalentries,
            ref int resume_handle);

        //--------------------------------------------------------------------------------------------------------------------
        // LOCALGROUP_MEMBERS_INFO_2
        //--------------------------------------------------------------------------------------------------------------------
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
        public struct LOCALGROUP_MEMBERS_INFO_2
        {
            public IntPtr lgrmi2_sid;   //x64だとおちるので int-->intPtrに変更した。
            public int lgrmi2_sidusage;
            [MarshalAs(UnmanagedType.LPWStr)]
            public string lgrmi2_domainandname;  //x64だとおちるので strubg-->intPtrに変更したが、[MarshalAs(UnmanagedType.LPWStr)]をいれたら大丈夫になった。
        }

        //--------------------------------------------------------------------------------------------------------------------
        // GetLocalGroupMembers
        //--------------------------------------------------------------------------------------------------------------------
        public static ArrayList GetLocalGroupMembers(STRUCT_strServerName_Original strServerName_Original, STRUCT_strNTAccount_ShortName strNTAccount_ShortName)
        {
            ArrayList arrayList = null;

            IntPtr nPtrBuffer = IntPtr.Zero;
            try
            {

                int nEntriesRead;
                int nTotalEntries;
                int nResume = 0;
                if (NetLocalGroupGetMembers(strServerName_Original.value, strNTAccount_ShortName.value, 2, out nPtrBuffer, -1, out nEntriesRead, out nTotalEntries, ref nResume) == APISuccess)
                {
                    if (nEntriesRead > 0)
                    {
                        LOCALGROUP_MEMBERS_INFO_2[] Members = new LOCALGROUP_MEMBERS_INFO_2[nEntriesRead];
                        arrayList = new ArrayList();

                        IntPtr iter = nPtrBuffer;

                        for (int i = 0; i < nEntriesRead; i++)
                        {
                            Members[i] = (LOCALGROUP_MEMBERS_INFO_2)Marshal.PtrToStructure(iter, typeof(LOCALGROUP_MEMBERS_INFO_2));
                            iter = (IntPtr)((int)iter + Marshal.SizeOf(typeof(LOCALGROUP_MEMBERS_INFO_2)));

                            ////x64だとおちるので strubg-->intPtrに変更したが、[MarshalAs(UnmanagedType.LPWStr)]をいれたら大丈夫になった。
                            //string strName = Marshal.PtrToStringAuto(Members[i].lgrmi2_domainandname);

                            //■これはユーザ管理での見た目と違い自動的にしてくれているので不要。
                            //string strTemp = Members[i].lgrmi2_domainandname;
                            //int nPos =strTemp.IndexOf(CAD_String.YEN);
                            //if(nPos==-1)
                            //{
                            //    //\マークないものはそのローカルユーザなのでサーバ名必要
                            //    strTemp = strServerName_Original.value  + CAD_String.YEN +   strTemp;
                            //}
                            //else
                            //{
                            //    if(nPos==0)
                            //    {
                            //        //頭に\マークがあれば、WellKnownのPrifixなしなので\マークのみはずす
                            //        strTemp = strTemp.Substring(CAD_String.YEN.Length);
                            //    }
                            //}

                            arrayList.Add(Members[i].lgrmi2_domainandname);
                        }
                    }
                }

            }
            finally
            {
                if (nPtrBuffer != IntPtr.Zero) NetApiBufferFree(nPtrBuffer);
            }

            return arrayList;

        }

        //--------------------------------------------------------------------------------------------------------------------
        // SampleGetLocalGroupMembers
        //--------------------------------------------------------------------------------------------------------------------

        static public void SampleGetLocalGroupMembers()
        {
            Console.WriteLine("Start SampleGetLocalGroupMembers");

            //Start SampleGetLocalGroupMembers
            //PC007\Administrator1
            //EXONE\Domain Admins2
            //EXONE\Domain Users2
            //PC007\test1
            //End SampleGetLocalGroupMembers

            ArrayList arrayList = new ArrayList();

            STRUCT_strServerName_Original strServerName_Original;
            strServerName_Original.value = "PC007";
            //arrayList = GetLocalGroupMembers(strServerName_Original, "administrators");
            ////string delimStr = ",";
            ////char[] delimiter = delimStr.ToCharArray();
            //foreach (string strTemp in arrayList)
            //{        
            //    //string[] split = null;
            //    //split = str.Split(delimiter);
            //    //Console.WriteLine(split[0] + split[1]);
            //    Console.WriteLine(strTemp);
            //}

            Console.WriteLine("End SampleGetLocalGroupMembers");
        }

//NetUserGetGroups グローバルグループの取得

        //--------------------------------------------------------------------------------------------------------------------
        // NetUserGetLocalGroups
        //--------------------------------------------------------------------------------------------------------------------
        [DllImport("Netapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        private extern static int NetUserGetLocalGroups([MarshalAs(UnmanagedType.LPWStr)] string servername,
            [MarshalAs(UnmanagedType.LPWStr)] string username,
            int level,
            int flags,
            out IntPtr bufptr,
            int prefmaxlen,
            out int entriesread,
            out int totalentries);

        //--------------------------------------------------------------------------------------------------------------------
        // LOCALGROUP_USERS_INFO_0
        //--------------------------------------------------------------------------------------------------------------------
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
        internal struct LOCALGROUP_USERS_INFO_0
        {
            [MarshalAs(UnmanagedType.LPWStr)]
            internal string name;
        }

        //--------------------------------------------------------------------------------------------------------------------
        // LOCALGROUP_USERS_INFO_1
        //--------------------------------------------------------------------------------------------------------------------
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
        internal struct LOCALGROUP_USERS_INFO_1
        {
            [MarshalAs(UnmanagedType.LPWStr)]
            public string name;
            [MarshalAs(UnmanagedType.LPWStr)]
            public string comment;
        }

        //--------------------------------------------------------------------------------------------------------------------
        // GetUserLocalGroups
        //--------------------------------------------------------------------------------------------------------------------
        static public ArrayList GetUserLocalGroups(STRUCT_strServerName_Original strServerName_Original, STRUCT_strNTAccount_ShortName strNTAccount_ShortName)
        {
            ArrayList arrayList = null;
            IntPtr nPtrBuffer = IntPtr.Zero;
            try
            {
                int nEntriesRead;
                int nTotalEntries;
                int nFlags = 0;

                if (NetUserGetLocalGroups(strServerName_Original.value, strNTAccount_ShortName.value, 0, nFlags, out nPtrBuffer, 1024, out nEntriesRead, out nTotalEntries) == APISuccess)
                {
                    if (nFlags > 1)
                    {
                        throw new Exception("Flags can only be 0 or 1");
                    }

                    if (nEntriesRead > 0)
                    {
                        LOCALGROUP_USERS_INFO_0[] RetGroups = new LOCALGROUP_USERS_INFO_0[nEntriesRead];
                        IntPtr nPtr = nPtrBuffer;

                        arrayList = new ArrayList();

                        for (int i = 0; i < nEntriesRead; i++)
                        {
                            RetGroups[i] = (LOCALGROUP_USERS_INFO_0)Marshal.PtrToStructure(nPtr, typeof(LOCALGROUP_USERS_INFO_0));
                            nPtr = (IntPtr)((int)nPtr + Marshal.SizeOf(typeof(LOCALGROUP_USERS_INFO_0)));
                            //ローカルのユーザはローカルグループしかわりあたらないので、頭に必ずサーバー名が必要
                            arrayList.Add(strServerName_Original.value + CAD_String.YEN + RetGroups[i].name);
                        }
                    }
                }
            }
            finally
            {
                if (nPtrBuffer != IntPtr.Zero) NetApiBufferFree(nPtrBuffer);
            }

            return arrayList;
        }

        //--------------------------------------------------------------------------------------------------------------------
        // GetUserLocalGroups
        //--------------------------------------------------------------------------------------------------------------------
        static public void SampleGetUserLocalGroups()
        {

            //Start SampleGetUserLocalGroups
            //Administrators
            //End SampleGetUserLocalGroups
            //Console.WriteLine("Start SampleGetUserLocalGroups");

            //Hashtable RetGroups = new Hashtable();
            //STRUCT_strServerName_Original strServerName_Original;
            //strServerName_Original.value = "PC007";
            //RetGroups = GetUserLocalGroups(strServerName_Original, "administrator");
            //Console.WriteLine("End SampleGetUserLocalGroups");
        }

//NetUserGetGroups ローカルグループの取得
        //これはない。ローカルでネットワークなんか追加できんからなんにつかうんだろう。
        ////--------------------------------------------------------------------------------------------------------------------
        //// NetUserGetGroups
        ////--------------------------------------------------------------------------------------------------------------------
        //[DllImport("Netapi32.dll", SetLastError = true)]
        //public extern static int NetUserGetGroups
        //    ([MarshalAs(UnmanagedType.LPWStr)] string servername,
        //     [MarshalAs(UnmanagedType.LPWStr)] string username,
        //     int level,
        //     out IntPtr bufptr,
        //     int prefmaxlen,
        //     out int entriesread,
        //     out int totalentries);

        //--------------------------------------------------------------------------------------------------------------------
        // GetUserNetGroups
        //--------------------------------------------------------------------------------------------------------------------
        //static private int ErrorCode;
        //static private string _ErrorMessage;

        //static public string ErrorMessage {
        //    get { return _ErrorMessage; }
        //}

        //static public ArrayList GetUserNetGroups(string ServerName,string Username, int Flags)
        //{
        //    ArrayList myList = new ArrayList();
        //    int EntriesRead;
        //    int TotalEntries;
        //    IntPtr bufPtr;

        //    ErrorCode = NetUserGetGroups(ServerName,Username,Flags,out bufPtr,1024,out EntriesRead, out TotalEntries);
        //    if(ErrorCode==0)
        //    {
        //        _ErrorMessage="Successful";
        //    }
        //    else
        //    {
        //        _ErrorMessage="Username or computer not found";
        //    }
        //
        //    if (nFlags > 1)
        //        _ErrorMessage = "Flags can only be 0 or 1";
        //    if (nEntriesRead > 0)
        //    {
        //        LOCALGROUP_USERS_INFO_0[] RetGroups = new LOCALGROUP_USERS_INFO_0[EntriesRead];
        //        IntPtr iter = bufPtr;
        //        for (int i = 0; i < EntriesRead; i++)
        //        {
        //            RetGroups[i] = (LOCALGROUP_USERS_INFO_0)Marshal.PtrToStructure(iter, typeof(LOCALGROUP_USERS_INFO_0));
        //            iter = (IntPtr)((int)iter + Marshal.SizeOf(typeof(LOCALGROUP_USERS_INFO_0)));
        //            myList.Add(RetGroups[i].name);
        //        }
        //        NetApiBufferFree(bufPtr);
        //    }
        //    return myList;
        //}

        ////--------------------------------------------------------------------------------------------------------------------
        //// Sample_GetUserNetGroups
        ////--------------------------------------------------------------------------------------------------------------------
        //public static void Sample_GetUserNetGroups()
        //{
        //    //Start Sample_GetUserNetGroups
        //    //なし
        //    //End Sample_GetUserNetGroups

        //    Console.WriteLine("Start Sample_GetUserNetGroups");
        //    //Example code for calling application
        //    ArrayList RetGroups = new ArrayList();
        //    RetGroups = GetUserNetGroups("PC007", "administrator", 0);
        //    foreach (string str in RetGroups)
        //    {
        //        Console.WriteLine(str);
        //    }

        //    Console.WriteLine("End Sample_GetUserNetGroups");
        //}

//NetShareEnum サーバの共有一覧
        //--------------------------------------------------------------------------------------------------------------------
        // NetShareEnum
        //--------------------------------------------------------------------------------------------------------------------
        [DllImport("Netapi32.dll", CharSet = CharSet.Auto)]
        private static extern int NetShareEnum(
             StringBuilder ServerName,
             int level,
             ref IntPtr bufPtr,
             uint prefmaxlen,
             ref int entriesread,
             ref int totalentries,
             ref int resume_handle
             );

        //--------------------------------------------------------------------------------------------------------------------
        // Variable
        //--------------------------------------------------------------------------------------------------------------------
        private const uint MAX_PREFERRED_LENGTH = 0xFFFFFFFF;
        private const int NERR_Success = 0;

        //--------------------------------------------------------------------------------------------------------------------
        // NetError 
        //--------------------------------------------------------------------------------------------------------------------
        private enum NetError : uint
        {
            NERR_Success = 0,
            NERR_BASE = 2100,
            NERR_UnknownDevDir = (NERR_BASE + 16),
            NERR_DuplicateShare = (NERR_BASE + 18),
            NERR_BufTooSmall = (NERR_BASE + 23),
        }
        //--------------------------------------------------------------------------------------------------------------------
        // SHARE_TYPE
        //--------------------------------------------------------------------------------------------------------------------
        public enum SHARE_TYPE : uint
        {
            STYPE_DISKTREE = 0,
            STYPE_PRINTQ = 1,
            STYPE_DEVICE = 2,
            STYPE_IPC = 3,
            STYPE_SPECIAL = 0x80000000,
        }

        //--------------------------------------------------------------------------------------------------------------------
        // SHARE_INFO_0
        //--------------------------------------------------------------------------------------------------------------------
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
        public struct SHARE_INFO_0
        {
            public string shi0_netname;
        }

        //--------------------------------------------------------------------------------------------------------------------
        // SHARE_INFO_1
        //--------------------------------------------------------------------------------------------------------------------
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
        public struct SHARE_INFO_1
        {
            public string shi1_netname;
            public uint shi1_type;
            public string shi1_remark;
            public SHARE_INFO_1(string sharename, uint sharetype, string remark)
            {
                this.shi1_netname = sharename;
                this.shi1_type = sharetype;
                this.shi1_remark = remark;
            }
            public override string ToString()
            {
                return shi1_netname;
            }
        }

        //--------------------------------------------------------------------------------------------------------------------
        // EnumNetShares
        //--------------------------------------------------------------------------------------------------------------------
        static public SHARE_INFO_1[] EnumNetShares(STRUCT_strServerName_Original strServerName_Original)
        {
            List<SHARE_INFO_1> ShareInfos = null;
            IntPtr nPtrBuffer = IntPtr.Zero;
            try
            {
                int nEntriesRead = 0;
                int nTotalEntries = 0;
                int nResume_handle = 0;
                int nStructSize = Marshal.SizeOf(typeof(SHARE_INFO_1));

                StringBuilder server = new StringBuilder(strServerName_Original.value);
                int ret = NetShareEnum(server, 1, ref nPtrBuffer, MAX_PREFERRED_LENGTH, ref nEntriesRead, ref nTotalEntries, ref nResume_handle);
                if (ret == NERR_Success)
                {
                    IntPtr currentPtr = nPtrBuffer;
                    for (int i = 0; i < nEntriesRead; i++)
                    {
                        SHARE_INFO_1 shi1 = (SHARE_INFO_1)Marshal.PtrToStructure(currentPtr, typeof(SHARE_INFO_1));

                        if (ShareInfos == null)
                        {
                            ShareInfos = new List<SHARE_INFO_1>();
                        }

                        ShareInfos.Add(shi1);
                        currentPtr = new IntPtr(currentPtr.ToInt32() + nStructSize);
                    }
                }
                else
                {
                    ShareInfos.Add(new SHARE_INFO_1("ERROR=" + ret.ToString(), 10, string.Empty));
                }
            }
            finally
            {
                if (nPtrBuffer != IntPtr.Zero) NetApiBufferFree(nPtrBuffer);
            }
            if (ShareInfos == null)
            {
                return null;
            }
            else
            {
                return ShareInfos.ToArray();
            }
        }

//NetShareGetInfo

        //--------------------------------------------------------------------------------------------------------------------
        // NetShareGetInfo
        //--------------------------------------------------------------------------------------------------------------------
        [DllImport("Netapi32", CharSet = CharSet.Auto)]
        private static extern int NetShareGetInfo(
            [MarshalAs(UnmanagedType.LPWStr)] string servername,
            [MarshalAs(UnmanagedType.LPWStr)] string netname,
            NetShareGetInfoLevel level,
            out IntPtr bufptr);

        //--------------------------------------------------------------------------------------------------------------------
        // NetShareGetInfoLevel
        //--------------------------------------------------------------------------------------------------------------------
        private enum NetShareGetInfoLevel
        {
            LEVEL_0 = 0,
            LEVEL_1 = 1,
            LEVEL_2 = 2,
            LEVEL_50 = 50,
            LEVEL_501 = 501,
            LEVEL_502 = 502,
            LEVEL_1005 = 1005,

        }

        //--------------------------------------------------------------------------------------------------------------------
        // SHARE_INFO_2
        //--------------------------------------------------------------------------------------------------------------------
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
        struct SHARE_INFO_2
        {
            [MarshalAs(UnmanagedType.LPWStr)]
            public string shi2_netname;
            public uint shi2_type;
            [MarshalAs(UnmanagedType.LPWStr)]
            public string shi2_remark;
            public uint shi2_permissions;
            public uint shi2_max_uses;
            public uint shi2_current_uses;
            [MarshalAs(UnmanagedType.LPWStr)]
            public string shi2_path;
            [MarshalAs(UnmanagedType.LPWStr)]
            public string shi2_passwd;
        }

        //--------------------------------------------------------------------------------------------------------------------
        // SHARE_INFO_502
        //--------------------------------------------------------------------------------------------------------------------
        [StructLayout(LayoutKind.Sequential)]
        struct SHARE_INFO_502
        {
            [MarshalAs(UnmanagedType.LPWStr)]
            public string shi502_netname;
            public uint shi502_type;
            [MarshalAs(UnmanagedType.LPWStr)]
            public string shi502_remark;
            public Int32 shi502_permissions;
            public Int32 shi502_max_uses;
            public Int32 shi502_current_uses;
            [MarshalAs(UnmanagedType.LPWStr)]
            public string shi502_path;
            public IntPtr shi502_passwd;
            public Int32 shi502_reserved;
            public IntPtr shi502_security_descriptor;
        }

        //--------------------------------------------------------------------------------------------------------------------
        // ERROR_CODE for ShareInfo
        //--------------------------------------------------------------------------------------------------------------------
        const int ERROR_ACCESS_DENIED = 5;
        const int ERROR_INVALID_LEVEL = 124; // unimplemented level for info
        const int ERROR_INVALID_PARAMETER = 87;
        const int ERROR_MORE_DATA = 234;
        const int ERROR_NOT_ENOUGH_MEMORY = 8;
        const int NERR_BufTooSmall = 2123; // The API return buffer is too small.
        const int NERR_NetNameNotFound = 2310; // This shared resource does not exist.

        //--------------------------------------------------------------------------------------------------------------------
        // FormatMessageShareInfo
        //--------------------------------------------------------------------------------------------------------------------
        static string NetShareGetInfo_FormatMessage(int errCode)
        {
            switch (errCode)
            {
                case ERROR_ACCESS_DENIED: return "The user does not have access to the requested information.";
                case ERROR_INVALID_LEVEL: return "The value specified for the level parameter is invalid.";
                case ERROR_INVALID_PARAMETER: return "The specified parameter is invalid.";
                case ERROR_MORE_DATA: return "More entries are available. Specify a large enough buffer to receive all entries.";
                case ERROR_NOT_ENOUGH_MEMORY: return "Insufficient memory is available.";
                case NERR_BufTooSmall: return "The supplied buffer is too small.";
                case NERR_NetNameNotFound: return "The share name does not exist.";
            };

            return null;
        }

        //--------------------------------------------------------------------------------------------------------------------
        // NetShareGetInfo_Path
        //--------------------------------------------------------------------------------------------------------------------
        public static string NetShareGetInfo_Path(STRUCT_strServerName_Original strServerName_Original, string strShareName)
        {
            IntPtr nPtrBuffer = IntPtr.Zero;

            try
            {
                string strPath = null;
                int errCode = NetShareGetInfo(strServerName_Original.value, strShareName, NetShareGetInfoLevel.LEVEL_2, out nPtrBuffer);
                if (errCode == NERR_Success)
                {
                    SHARE_INFO_2 shareInfo = (SHARE_INFO_2)Marshal.PtrToStructure(nPtrBuffer, typeof(SHARE_INFO_2));
                    strPath = shareInfo.shi2_path;
                }
                else
                {
                    //Console.WriteLine(NetShareGetInfo_FormatMessage(errCode));
                }

                return strPath;
            }
            finally
            {
                if (nPtrBuffer != IntPtr.Zero) NetApiBufferFree(nPtrBuffer);
            }

        }

        //--------------------------------------------------------------------------------------------------------------------
        // NetShareGetInfo_DACL
        //--------------------------------------------------------------------------------------------------------------------
        //Administrators または Account Operators ローカルグループのメンバ、
        //あるいは Communication Operators、Print Operators、Server Operators 
        //のいずれかのグループのメンバだけがレベル 2(502含む) を指定してこの関数を実行できます。
        //レベル 0 またはレベル 1 を指定して実行する場合、特別なグループメンバーシップは必要ありません。

        //・9x系(98, ME等)
        //レベル1: 共有名、種類、コメント
        //レベル50: 共有名、種類、アクセス権、コメント、パス、パスワード、書込パスワード、読取パスワード

        //・NT系(XP, Vista等)
        //レベル0: 共有名
        //レベル1: 共有名、種類、コメント
        //レベル2: 共有名、種類、アクセス許可、最大接続数、現接続数、パス、パスワード
        //レベル501: 共有名、種類、コメント
        //レベル502: 共有名、種類、アクセス許可、最大接続数、現接続数、パス、パスワード、セキュリティ記述子
        //レベル503: 共有名、種類、アクセス許可、最大接続数、現接続数、パス、パスワード、サーバー名、セキュリティ記述子
        //レベル1004: コメント
        //レベル1005: DFSルート内のDFSリンクか否か
        //レベル1005: 最大接続数
        //レベル1501: セキュリティ記述子
        public const string NETSHAREGETINFO_DACL_ISNULL = "①「Administrators または Account Operators ローカルグループのメンバ、あるいは Communication Operators、Print Operators、Server Operators のいずれかのグループのメンバだけが共有情報を参照できます。」②「 Windows XP, Vista等の簡易ネットワーク共有の場合は権限が表示できません。」";

        static public CaD_API_Advapi32.STRUCT_ACE[] NetShareGetInfo_DACL(STRUCT_strServerName_Original strServerName_Original, string strShareName)
        {
            IntPtr nPtrBuffer = IntPtr.Zero;

            try
            {
                int ret = NetShareGetInfo(strServerName_Original.value, strShareName, NetShareGetInfoLevel.LEVEL_502, out nPtrBuffer);
                if (ret == NERR_Success)
                {
                    SHARE_INFO_502 shareInfo = (SHARE_INFO_502)Marshal.PtrToStructure(nPtrBuffer, typeof(SHARE_INFO_502));
                    try
                    {
                        return CaD_API_Advapi32.GetDACL_ACEs(shareInfo.shi502_security_descriptor);
                    }
                    catch
                    {
                        //エラーの場合はとりあえずNullで返す。
                        return null;
                    }
                    finally
                    {
                        //502初期化(★これはいらんだろう、やると逆にやばい?)
                        //if (shareInfo.shi502_security_descriptor != IntPtr.Zero) CaD_API_Kernel32.LocalFree(shareInfo.shi502_security_descriptor);
                        //if (shareInfo.shi502_passwd != IntPtr.Zero) CaD_API_Kernel32.LocalFree(shareInfo.shi502_passwd);
                    }
                }
                else
                {
                    //なかったらNullでかえす。
                    return null;
                }
            }
            finally
            {
               if (nPtrBuffer != IntPtr.Zero) NetApiBufferFree(nPtrBuffer);
            }
        }
        //--------------------------------------------------------------------------------------------------------------------
        // NetShareGetInfo1
        //--------------------------------------------------------------------------------------------------------------------
        static public int NetShareGetInfo1(string strServerName, string strShareName, ref SHARE_INFO_1 shareInfo)
        {
            IntPtr nPtrBuffer = IntPtr.Zero;

            try
            {
                int ret = NetShareGetInfo(strServerName, strShareName, NetShareGetInfoLevel.LEVEL_1, out nPtrBuffer);
                if (ret == NERR_Success)
                {
                    shareInfo = (SHARE_INFO_1)Marshal.PtrToStructure(nPtrBuffer, typeof(SHARE_INFO_1));
                }
                return ret;
            }
            finally
            {
                if (nPtrBuffer != IntPtr.Zero) NetApiBufferFree(nPtrBuffer);
            }

        }

    }
}

Filed Under: FAD開発

About the Author

野呂清二(ご連絡はこちらまで (http://www.exceedone.co.jp/inquiry/)

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.