Exemple #1
0
        /// <summary>
        /// Parses command line arguments.
        /// Calls API <msdn>CommandLineToArgvW</msdn>.
        /// Returns empty array if s is null or "".
        /// </summary>
        public static unsafe string[] CommandLineToArray(string s)
        {
            if (s.NE())
            {
                return(Array.Empty <string>());
            }
            char **p = Api.CommandLineToArgvW(s, out int n);
            var    a = new string[n];

            for (int i = 0; i < n; i++)
            {
                a[i] = new string(p[i]);
            }
            Api.LocalFree(p);
            return(a);
        }
    unsafe static void Main(string[] args)
    {
        int    num;
        void * pnt    = &num;
        byte * pntb1  = (byte *)pnt;
        byte * pntb2  = (byte *)pnt + 1;
        byte * pntb3  = (byte *)pnt + 2;
        byte * pntb4  = (byte *)pnt + 3;
        char * pntc   = (char *)pntb1;
        char **pntpnt = &pntc;

        **pntpnt = 'A';
        pntc = (char *)pntb2;
        **pntpnt = 'A';
        pntc = (char *)pntb3;
        **pntpnt = 'B';
        pntc = (char *)pntb4;
        **pntpnt = 'B';

        Console.WriteLine(num);
        Console.WriteLine($"| {(char)pntb1[0]} | {(char)pntb2[0]} | {(char)pntb3[0]} | {(char)pntb4[0]} |");
        Console.ReadKey();
    }