Advertisement
Morogn93

wpf console

May 9th, 2024
831
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System.Text;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Data;
  5. using System.Windows.Documents;
  6. using System.Windows.Input;
  7. using System.Windows.Media;
  8. using System.Windows.Media.Imaging;
  9. using System.Windows.Navigation;
  10. using System.Windows.Shapes;
  11. using System.Runtime.InteropServices; // adding Console
  12.  
  13. namespace WpfAppHurst
  14. {
  15.     /// <summary>
  16.     /// Interaction logic for MainWindow.xaml
  17.     /// </summary>
  18.     public partial class MainWindow : Window
  19.     {
  20.  
  21.         [DllImport("Kernel32")]
  22.         public static extern void AllocConsole();
  23.  
  24.         [DllImport("Kernel32", SetLastError = true)]
  25.         public static extern void FreeConsole();
  26.  
  27.         /// <summary>
  28.         /// Copilot
  29.         /// </summary>
  30.         public MainWindow()
  31.         {
  32.             InitializeComponent();
  33.             AllocConsole();
  34.             ConsoleMethod(null);
  35.         }
  36.  
  37.  
  38.         public void ConsoleMethod(Object param)
  39.         {
  40.             Console.WriteLine("test");
  41.         }
  42.  
  43.        
  44.     }
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement