1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
$CodigoC = @" using System; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; namespace Formulario { public class Principal : Form { private Button btnHello; public Principal() { this.Text = "Formulario"; // Botón btnHello = new Button(); btnHello.Location = new Point(89, 12); btnHello.Name = "btnHello"; btnHello.Size = new Size(105, 30); btnHello.Text = "Pulsar"; // Evento de pulsar al botón btnHello.Click += new EventHandler(btnHello_Click); this.Controls.Add(btnHello); } // Evento pulsar botón private void btnHello_Click(object sender, EventArgs e) { MessageBox.Show("Hola mundo"); } [STAThread] public void Main() { Application.EnableVisualStyles(); Application.Run(new Principal()); } } } "@ Add-Type -TypeDefinition $CodigoC -ErrorAction SilentlyContinue -ReferencedAssemblies System,System.Windows.Forms,System.ComponentModel,System,System.Drawing [Formulario.Principal]::new().Main() |