示例#1
0
        public Argv(string[] args, bool add_program_name)
        {
            add_progname = add_program_name;
            if (add_progname)
            {
                string[] full = new string [args.Length + 1];
                full [0] = System.Environment.GetCommandLineArgs()[0];
                args.CopyTo(full, 1);
                args = full;
            }

            arg_ptrs = new IntPtr [args.Length];

            for (int i = 0; i < args.Length; i++)
            {
                arg_ptrs [i] = Marshaller.StringToPtrGStrdup(args[i]);
            }

            handle = Marshaller.Malloc((ulong)(IntPtr.Size * args.Length));

            for (int i = 0; i < args.Length; i++)
            {
                Marshal.WriteIntPtr(handle, i * IntPtr.Size, arg_ptrs [i]);
            }
        }