简体   繁体   English

通过process.start()打开特定版本的Flash

[英]Opening particular version of Flash by process.start()

I am using the following code to open flash: 我正在使用以下代码打开Flash:

private Process flash = new Process();
flash.StartInfo.FileName = ("Flash.exe");
flash.Start();

The target machine has many version of flash like flash cs5,4,3. 目标计算机具有许多版本的Flash,例如Flash CS5、4、3。 I want to open the newest version or let the user choose, how can I possibly do that? 我想打开最新版本或让用户选择,我该怎么做?

Typically speaking, all other flash installations would be in different program folders, so you would just need to make sure you're running Flash.exe from the right folder. 通常来讲,所有其他Flash安装都位于不同的程序文件夹中,因此您只需要确保从正确的文件夹中运行Flash.exe即可。 For instance, my current installation lies here: C:\\Program Files (x86)\\Adobe\\Adobe Flash CS5\\Flash.exe , but an alternate one could very well be in C:\\Program Files (x86)\\Adobe\\Adobe Flash CS4\\Flash.exe`. 例如,我当前的安装位于: C:\\Program Files (x86)\\Adobe\\Adobe Flash CS5\\Flash.exe ,但另一种安装方式很可能位于C:\\ Program Files(x86)\\ Adob​​e \\ Adob​​e Flash CS4 \\ Flash.exe`。

An important thing to notice is that you can't assume the user installed flash CS* in its default directory ! 需要注意的重要一点是, 您不能假定用户将Flash CS *安装在其默认目录中 You should always query the Windows registry to find the list of installed products. 您应该始终查询Windows注册表以找到已安装产品的列表。

Also, another notice would be that you don't need parentheses around string literals. 另外,另一个注意事项是,您不需要在字符串文字周围加上括号。 So you can just write: 所以你可以这样写:

string foo = "Hello!";

instead of 代替

string foo = ("Hello!");

Edit 1: 编辑1:

Hey, I found a similar problem being treated in a forum thread here ! 嘿,我在这里论坛主题中发现了类似的问题! I downloaded the code sample and ran it through a vb.net -> C# converter ( like this one ) and got it to work after a few minor syntax tweaks. 我下载了代码示例,并通过vb.net-> C#转换器( 像这样 )运行了该示例,并在进行了一些次要的语法调整后使其工作。 Now it's able to output a list of the installed programs with their appropriate version numbers. 现在,它可以输出已安装程序的列表及其相应的版本号。

There will be a bunch of methods that get programs form eg certain users. 将有很多方法可以从某些用户那里获取程序。 All of these will then be placed in a common list, returned to the user. 所有这些都将放在一个公用列表中,并返回给用户。 Now, this seems perfect, but there is just one flaw - no path is available... so far! 现在,这似乎是完美的,但是只有一个缺陷-到目前为止没有可用的路径!

You can just query the UninstallString, and get a path to the uninstaller (which is IIRC in the same folder as Flash.exe). 您可以只查询UninstallString,并获取到卸载程序的路径(与Flash.exe位于同一文件夹中的IIRC)。 For instance, in GetUninstallKeyPrograms, after the 例如,在GetUninstallKeyPrograms中,

try
{
    IsSystemComponent = Convert.ToInt32(CurrentSubKey.GetValue("SystemComponent", 0));
}

snippet, you can try to get the UninstallString value in order to obtain the path. 片段,您可以尝试获取UninstallString值以获取路径。 Hope it helps! 希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM