あにす #6184(2008/04/19 14:08 GMT) [ C# ] Rating1/1=1.00
see: 貧脚レーサーのサボり日記
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
using System; using System.Windows.Forms; using Microsoft.VisualBasic.ApplicationServices; namespace ConsoleApplication1 { static class Program { [STAThread] static void Main(string[] args) { //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new Form1()); myApplication winAppBase = new myApplication(); winAppBase.Run(args); } } class myApplication :WindowsFormsApplicationBase { public myApplication() : base() { this.EnableVisualStyles = true; this.IsSingleInstance = true; this.MainForm = new Form();//スタートアップフォームを設定 this.StartupNextInstance += new StartupNextInstanceEventHandler(myApplication_StartupNextInstance); } void myApplication_StartupNextInstance(object sender, StartupNextInstanceEventArgs e) { //ここに二重起動されたときの処理を書く //e.CommandLineでコマンドライン引数を取得出来る string cmd = ""; foreach(string str in e.CommandLine) { cmd += str + Environment.NewLine; } MessageBox.Show(cmd); } } }
Rating1/1=1.00-0+
[ reply ]
あにす
#6184()
[
C#
]
Rating1/1=1.00
後から起動されようとした実行ファイルに渡されたコマンドライン引数を取得、表示して下さい。
.NET Framework上のWindowsアプリケーションではこんな方法があります。
VBのWindowsFormsApplicationBaseクラスを利用するので
Microsoft.VisualBasicを参照に加えます。
see: 貧脚レーサーのサボり日記
Rating1/1=1.00-0+
[ reply ]