This article is a mirror article of machine translation, please click here to jump to the original article.

View: 43987|Reply: 1

[WPF] WPF settings and getting launch parameters

[Copy link]
Posted on 12/8/2015 11:50:30 AM | | | |


Before the WPF program starts, get the startup parameters with the following code:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Windows;

  7. namespace WpfFistDemo
  8. {
  9.     /// <summary>
  10.     /// App.xaml 的交互逻辑
  11.     /// </summary>
  12.     public partial class App : Application
  13.     {
  14.         protected override void OnStartup(StartupEventArgs e)
  15.         {
  16.             if (e.Args.Length > 0)
  17.             {
  18.                 var window = new MainWindow();
  19.                 //window.ShowEx("a");
  20.             }
  21.             else
  22.             {
  23.                 string a = "码农网";
  24.                 var window = new MainWindow();
  25.                 window.ShowEx(a);
  26.             }
  27.         }
  28.     }
  29. }
Copy code

  1.         /// <summary>
  2.         /// 获取启动参数
  3.         /// </summary>
  4.         /// <param name="args"></param>
  5.         public void ShowEx(string args)
  6.         {
  7.             MessageBox.Show(args);
  8.         }
Copy code






Previous:Google Mirror Station Collection | Google Mirror Station - No need to climb the wall of Google
Next:WPF closes windows and processes
Posted on 11/3/2021 10:10:17 AM |
Well, let's take a look at how the gods are written
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com