note : GetExitCodeProcess
来源:互联网 发布:周易算卦知乎 编辑:程序博客网 时间:2024/05/22 18:41
// ExitCodeRecv.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <windows.h>#include <tchar.h>/** 有个安装程序,安装结束(安装成功,安装失败)后, 会写一个.ini文件 可以从中读安装结果值. 对于非定制程序, 可以读取程序的退出码. 效果应该是一样的 而且读取程序退出码,比读取安装程序的ini输出文件要简洁.*/int _tmain(int argc, _TCHAR* argv[]){ BOOL bRc = FALSE; STARTUPINFO si; PROCESS_INFORMATION pi; WCHAR cCmdLine[MAX_PATH]; DWORD dwExitCode = 0; ::ZeroMemory(&si, sizeof(STARTUPINFO)); si.cb = sizeof(STARTUPINFO); ::ZeroMemory(&pi, sizeof(PPROCESS_INFORMATION)); ::ZeroMemory(cCmdLine, sizeof(cCmdLine)); wcscpy_s(cCmdLine, L"D:\\LsWorkDir\\Demo\\testExitCode\\subProg\\bin\\ExitCodeSend.exe"); bRc = ::CreateProcessW( NULL, cCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); if (!bRc) { _tprintf(L"Error CreateProcessW \r\n"); goto _tmain_END; } WaitForSingleObject(pi.hProcess, INFINITE); bRc = GetExitCodeProcess(pi.hProcess, &dwExitCode); if (!bRc) { _tprintf(L"Error CreateProcessW \r\n"); goto _tmain_END; } _tprintf(L"subProg dwExitCode = 0x%X\r\n", dwExitCode);_tmain_END: if (NULL != pi.hProcess) CloseHandle(pi.hProcess); if (NULL != pi.hThread) CloseHandle(pi.hThread); getwchar(); return 0;}
// ExitCodeSend.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <windows.h>#include <tchar.h>#include <time.h>int _tmain(int argc, _TCHAR* argv[]){ int iRc = 0; srand((UINT)time(NULL)); iRc = rand(); _tprintf(L"return code = 0x%X\r\n", iRc); getwchar();return iRc;}
测试程序的输出都打到调用者UI上了.
return code = 0x6980subProg dwExitCode = 0x6980
- note : GetExitCodeProcess
- GetExitCodeProcess
- OpenProcess、GetExitCodeProcess、TerminateProcess
- note
- note
- NOTE
- note
- Note
- note
- note
- Note
- note
- Note
- Note
- note
- Note
- Note
- Note
- 一个APP应用开发技术负责人需要了解的东西
- selection does not contain a main type
- 实现LinkedList
- mac下svn问题 —— “.a”(静态库)文件无法上传
- vs2005无法附加进程
- note : GetExitCodeProcess
- u-Boot环境变量的设置
- 新手程序猿如何区分输入流和输出流?
- 2013年11月11日--12月19日(总共50小时,剩4822小时)
- HDU1710利用二叉树的先序和中序输出后序
- Rotate bits of a number 左旋转或右旋转一个数 @GFG
- HDOJ 1003 Max Sum
- PDF 文件书签计划
- 9.png图片制作 — 图文详解