【发布时间】:2013-06-08 21:19:59
【问题描述】:
我使用 innosetup 来安装我的应用程序。 例如,所有文件都在程序文件\测试中 在目录中,我有我的程序的 exe 文件,还有 ffmpeg.exe
现在在我的代码中我做了:
class Ffmpeg
{
NamedPipeServerStream p;
String pipename = "mytestpipe";
byte[] b;
System.Diagnostics.Process process;
string ffmpegFileName;
string workingDirectory;
public Ffmpeg()
{
workingDirectory = Path.GetDirectoryName(Application.LocalUserAppDataPath) + @"\workingDirectory";
ffmpegFileName = @"\ffmpeg.exe";
if (!Directory.Exists(workingDirectory))
{
Directory.CreateDirectory(workingDirectory);
}
ffmpegFileName = workingDirectory + ffmpegFileName;
Logger.Write("Ffmpeg Working Directory: " + ffmpegFileName);
}
public void Start(string pathFileName, int BitmapRate)
{
try
{
string outPath = pathFileName;
Logger.Write("Output Video File Directory: " + outPath);
Logger.Write("Frame Rate: " + BitmapRate.ToString());
p = new NamedPipeServerStream(pipename, PipeDirection.Out, 1, PipeTransmissionMode.Byte);
b = new byte[1920 * 1080 * 3]; // some buffer for the r g and b of pixels of an image of size 720p
ProcessStartInfo psi = new ProcessStartInfo();
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
psi.FileName = ffmpegFileName;
psi.WorkingDirectory = workingDirectory;
问题是workingDirectory目录不包含安装后的ffmpeg.exe。因此,如果用户在安装后第一次运行该程序,则该文件将丢失。
我将 ffmpeg.exe 添加到我的项目中并将其设置为:Content and Copy always
我想做的是以某种方式将workingDirectory设置为用户安装程序的位置,如果它是程序文件或任何其他目录。
或者将workigDirectory设置为我已经添加到项目中的文件ffmpeg.exe。
问题是安装后用户将运行程序并且目录workingDirectory将为空。
【问题讨论】:
-
所以在安装过程中为用户选择的安装路径设置一个注册表项。在您的应用程序中读取该路径
-
我认为您没有正确创建安装包。一个工作的安装包会非常完整,以至于用户什么都不用做。安装后,开始菜单中有一些快捷方式,您的用户可以在其中找到如何运行您的应用程序。