execute.cpp

来自「A Model-View-Controller Framework that i」· C++ 代码 · 共 51 行

CPP
51
字号
#include "stdafx.h"
#include "Execute.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

namespace SbjCore
{
	namespace Sys
	{
	
		bool Execute(LPCTSTR lpszExe, LPCTSTR lpszCmdLine)
		{
			bool bRslt = false;
			
			if ((lpszExe != NULL) && (_tcslen(lpszExe) > 0))
			{
				SHELLEXECUTEINFO theInfo;

				ZeroMemory(&theInfo, sizeof(theInfo));

				theInfo.cbSize = sizeof(SHELLEXECUTEINFO);
				theInfo.lpVerb = _T("Open");
				theInfo.nShow = SW_SHOW;
				theInfo.lpFile = lpszExe;
				theInfo.lpParameters = lpszCmdLine;

				if (::ShellExecuteEx(&theInfo) == FALSE)
				{
					TRACE(_T("ShellExecuteEx() failed with %ul.\n"), ::GetLastError());
				}
				else
				{
					TRACE(_T("ShellExecuteEx() succeeded.\n"));

					bRslt = true;
				}
			}
			return bRslt;
		}

	}
}

//*** Modification History ***
// $Log:  $

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?