[System.Runtime.InteropServices.DllImport("shell32.dll")]
public static extern int ShellExecute(IntPtr hwnd, StringBuilder lpszOp, StringBuilder lpszFile, StringBuilder lpszParams, StringBuilder lpszDir, int FsShowCmd);
引用这个代码,然后再你需要关闭的时候进行调用
例如:
ShellExecute(IntPtr.Zero, new StringBuilder("Open"), new StringBuilder("xxxx.exe"), new StringBuilder(""), new StringBuilder(path), 1);
只需要更改:xxxx.exe改为你需要更改的程序名称,path为需要打开程序的路径 ,其他都不用变
本文介绍如何在C#中使用System.Runtime.InteropServices.DllImport属性导入shell32.dll库,通过ShellExecute函数调用外部程序。只需修改目标程序名称和路径即可实现。
951

被折叠的 条评论
为什么被折叠?



