用ShellExecuteEx和TerminateProcess打开和关闭文件

#include 
#include 
#include 

using namespace std;

int main()
{
	SHELLEXECUTEINFO seo;
	memset(&seo, 0, sizeof(SHELLEXECUTEINFO));
	seo.cbSize = sizeof(SHELLEXECUTEINFO);
	seo.fMask = SEE_MASK_NOCLOSEPROCESS;
	seo.nShow = SW_SHOWNORMAL;
	seo.lpVerb = _T("open");

	seo.lpDirectory = _T("E:\\ResTxt");
	seo.lpFile = _T("Test.txt");

	//seo.lpFile = _T("notepad.exe");

	//seo.lpFile = _T("www.baidu.com");
	

	BOOL flag = ShellExecuteEx(&seo);//open file

	if (flag == TRUE)
	{
		cout << "Success!"<
参考:http://www.cppblog.com/SpringSnow/archive/2009/04/22/80719.html

你可能感兴趣的:(C++)