_LocalFree() 개인적인 메소드

private _LocalFree ( IntPtr hMem ) : IntPtr
hMem IntPtr
리턴 IntPtr
예제 #1
0
        public static string[] CommandLineToArgvW(string cmdLine)
        {
            IntPtr intPtr = IntPtr.Zero;

            string[] result;
            try
            {
                int num = 0;
                intPtr = NativeMethods._CommandLineToArgvW(cmdLine, out num);
                if (intPtr == IntPtr.Zero)
                {
                    throw new Win32Exception();
                }
                string[] array = new string[num];
                for (int i = 0; i < num; i++)
                {
                    IntPtr ptr = Marshal.ReadIntPtr(intPtr, i * Marshal.SizeOf(typeof(IntPtr)));
                    array[i] = Marshal.PtrToStringUni(ptr);
                }
                result = array;
            }
            finally
            {
                IntPtr intPtr2 = NativeMethods._LocalFree(intPtr);
            }
            return(result);
        }