0

Visual C++ でアプリケーションを作成しました (コマンド ラインを使用します)。ユーザーがコマンドラインを使用する必要がなく、GUI から実行できるように、Visual C# で同じ GUI を作成しました。では、同じインストーラーを作成するにはどうすればよいでしょうか。GUI には、アプリケーションを呼び出して実行する次のコードがあります。

                string cmdText;
                cmdText = @"C++HeaderConversionToQFASTXML.exe " + " " + textBox1.Text + " " + textBox2.Text;
                ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
                info.UseShellExecute = false;
                info.RedirectStandardInput = true;
                info.RedirectStandardOutput = true;
                info.CreateNoWindow = true;
                info.WorkingDirectory = @"C:\forAbishek\C++HeaderConversionToQFASTXML\Release\";
                Process p = Process.Start(info);
                p.StandardInput.WriteLine(cmdText);

この場合、作業ディレクトリを、.exe (C++HeaderConversionToQFASTXML.exe) がユーザーのマシンに存在するディレクトリにする必要があります。GUI がこれを確実に取得するにはどうすればよいですか? .exe がユーザーのマシンにインストールされます。誰かが私を助けることができますか?ありがとうございました。

次の変更を行いました。

                    string cmdText;
                    cmdText = @"C++HeaderConversionToQFASTXML.exe " + " " + textBox1.Text + " " + textBox2.Text;
                    ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
                    info.UseShellExecute = false;
                    info.RedirectStandardInput = true;
                    info.RedirectStandardOutput = true;
                    info.CreateNoWindow = true;
                    String path = System.Reflection.Assembly.GetExecutingAssembly().Location;
                    path = System.IO.Path.GetDirectoryName(path);
                    Directory.SetCurrentDirectory(path);
                    MessageBox.Show(path);
                    info.WorkingDirectory = path;
                    Process p = Process.Start(info);
                    p.StandardInput.WriteLine(cmdText);

まだ機能していません。どこが間違っていますか?

4

1 に答える 1

1

Unless there is a reason you can't do so, I'd suggest configuring the installer to put the CLI and GUI executables in the same location and skip the whole relative path issue entirely.

If you want to allow the user to create non-default post-install configurations where the apps are in different locations, add an app.info file for your C# app where the user can specify the location of the CLI app if it's not in the same folder as the UI.

I'm not aware of any easy way to specify two different locations in an installer and use them to dynamically create/modify an app.info file. If you need that I think you'll need to write a custom config app that's called by the installer to create the app.info file.

于 2012-09-11T21:13:15.833 に答える