怎么用.net程序启动word

来源:百度知道 编辑:UC知道 时间:2024/06/02 14:52:17
怎么用.net程序启动本机word

本人因分数不多,所以只能给五分,请大家帮忙!!!
可能每个人本机上安装word的路经不同,死路会不会有问题

Process.start(string file);
file是文件名或文件路径

先访问注册表,得到执行文件路径。

Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey( @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe" );
if ( key != null )
{
try
{
System.Diagnostics.Process.Start( key.GetValue( "Path" ) + "Winword.exe" );
}
catch ( System.ComponentModel.Win32Exception ex )
{
Console.WriteLine( ex.Message );
}
}