public bool Run(Form mainForm) { var commandLineArgs = Environment.GetCommandLineArgs(); if (commandLineArgs.Length > 1) // コマンドライン引数があれば { DocumentPath = commandLineArgs[1]; // ドキュメント ファイルのパスとする } using (var singleDocumentApplication = new SingleDocumentHelper.Application()) { if (singleDocumentApplication.Initialize(new Ticker(), DocumentPath, sourcePath => DocumentPath = sourcePath)) { Application.Run(mainForm); return(true); } return(false); // 他のプロセスが既に起動していれば終了 } }