首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C#怎么运行一个外部程序

2012-01-26 
C#如何运行一个外部程序比如说我想通过C#程序启动PowerPoint,但是我并不知道PowerPoint主程序的路径。也就

C#如何运行一个外部程序
比如说我想通过C#程序启动Power   Point,但是我并不知道Power   Point主程序的路径。

也就是说:
1、如何找到PPT主程序的路径。
2、如何通过程序启动PPT。
3、在适当的时候关闭PPT,或者即使C#程序结束,PPT也不关闭。

请大家赐教。

[解决办法]
比如:
Process.Start( "IExplore.exe ", "C:\\myPath\\myFile.asp ");

或用其它的Start重载函数来运行
[解决办法]
要找到ppt主程序的路径,注册表里应该有
要运行ppt,直接System.Diagnostics.Process.Start( "filename ");就行
[解决办法]
你可以这样来取这个值,因为这个键是默认名字,可以用String.Empty或 " "来取,如下:

RegistryKey PowerPointKey = Registry.ClassesRoot.OpenSubKey( "MSPowerPoint\\protocol\\StdFileEditing\\server ");
object value = PowerPointKey.GetValue( " ");
string strPowerPointPath = value as string;

或:

RegistryKey PowerPointKey = Registry.ClassesRoot.OpenSubKey( "MSPowerPoint\\protocol\\StdFileEditing\\server ");
object value = PowerPointKey.GetValue(string.Empty);
string strPowerPointPath = value as string;

[解决办法]
直接运行就行了...

for example:

Process.Start(@ "E:\test.ppt ");

热点排行