using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;


namespace TestMarshalApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int[] test1 = new int[5];

            _DTestMarshal ifArrayTest = null;
            object TestMarshalObj;

            for (int i = 0; i < 5; i++)
                test1[i] = (int)(100 + i);

            Type typeofMarshal = Type.GetTypeFromProgID("TESTMARSHAL.TestMarshalCtrl.1");

            if (typeofMarshal == null)
                Marshal.ThrowExceptionForHR(0);

            TestMarshalObj = Activator.CreateInstance(typeofMarshal);
            ifArrayTest = (_DTestMarshal)TestMarshalObj;

            if (ifArrayTest == null)
                return;

            ifArrayTest.SetArrayTest(test1);

            ifArrayTest.SetArrayTest1(1);

        }

        private void button2_Click(object sender, EventArgs e)
        {
            axTestMarshal2.SetArrayTest1(1);
        }
    }
}
