15,473
社区成员




SHELLEXECUTEINFO appInfo;
ZeroMemory(&appInfo, sizeof(SHELLEXECUTEINFO));
appInfo.cbSize = sizeof(SHELLEXECUTEINFO);
appInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
appInfo.lpVerb = L"open";
appInfo.lpFile = lpFilePath.c_str();
appInfo.nShow = SW_SHOWDEFAULT;
// open the decrypted file
BOOL bResult = ShellExecuteEx(&appInfo);
if ( bResult )
{
if ( NULL != appInfo.hProcess )
{
DWORD dwRes = WaitForSingleObject(appInfo.hProcess, INFINITE);
CloseHandle(appInfo.hProcess);
}
}
// delete the destination file which temporary decrypted
deleteFiles(lpFilePath, FALSE);
PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
STARTUPINFO si = {sizeof(si)};
BOOL bResult = CreateProcess(NULL,
chCommandLine,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi);
if ( !bResult )
{
DWORD dwErrorCode = GetLastError();
FPString str(L"Create Process failed");
str.append(getErrorCodeString(dwErrorCode));
MessageBoxW(NULL, str.c_str(), L"Error", MB_OK | MB_ICONERROR);
}
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
// delete the destination file which temporary decrypted
deleteFiles(lpFileInfos, FALSE);
DWORD WINAPI ExpandEnvironmentStrings(
__in LPCTSTR lpSrc,
__out LPTSTR lpDst,
__in DWORD nSize
);
wstring strCommandLine; //它的值就是命令行字符串
INT pos = (INT)strCommandLine.find(L"%1");
if ( -1 != pos )
{
strCommandLine.replace(pos, 2, strDestFilePath); //strDestFilePath是要文件的路径类型是wstring
}
else
{
strCommandLine.append(L" \"").append(lpFileInfos->m_sDestFileInfo.m_szDestFilePath).append(L"\"");
}
PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
STARTUPINFO si = {sizeof(si)};
BOOL bResult = CreateProcess(NULL,
chCommandLine,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi);
if ( !bResult )
{
DWORD dwErrorCode = GetLastError();
FPString str(L"Create Process failed");
str.append(getErrorCodeString(dwErrorCode));
MessageBoxW(NULL, str.c_str(), L"Error", MB_OK | MB_ICONERROR);
}
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
// delete the destination file which temporary decrypted
deleteFiles(lpFileInfos, FALSE);