在C#中,怎样调出系统的计事本来啊!
有用急用!
在此,先谢谢了
有用急用!
在此,先谢谢了
解决方案 »
- 问一个比较有美感的问题
- 谁能帮我改下代码?急~~~~~~~
- Single Document模式下Dialog的添加
- 同时使用定时器出错!请教各位高手
- 请问,为什么等号右边的stl::map 的[]操作会让元素增加???!!
- 如何遍历文件夹下的所有文件,并要求每次都得到文件名
- 如何将一个程序从release版转变成debug版?谢谢。
- 问一个select语句的问题
- 请教如何学习VC
- UDP中使用,为什么取不到对端的IP和端口?
- 引用系统Dll C:\windows\system32\*.dll 能不能不取得这位置的Dll 从exe所在的当前目录读取dll文件?
- vc如何实现vb的str(i as long)函数功能?
using System;
using System.Diagnostics;
using System.ComponentModel;namespace MyProcessSample
{
/// <summary>
/// Shell for the sample.
/// </summary>
class MyProcess
{
// These are the Win32 error code for file not found or access denied.
const int ERROR_FILE_NOT_FOUND =2;
const int ERROR_ACCESS_DENIED = 5; /// <summary>
/// Prints a file with a .doc extension.
/// </summary>
void PrintDoc()
{
Process myProcess = new Process();
try
{
// Get the path that stores user documents.
myProcess.StartInfo.FileName = "notepad.exe";
myProcess.StartInfo.Verb = "open";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
}
catch (Win32Exception e)
{
if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
{
Console.WriteLine(e.Message + ". Check the path.");
} else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
{
// Note that if your word processor might generate exceptions
// such as this, which are handled first.
Console.WriteLine(e.Message +
". You do not have permission to print this file.");
}
}
}
public static void Main()
{
MyProcess myProcess = new MyProcess();
myProcess.PrintDoc();
}
}
}