note : GetExitCodeProcess
发布日期:2021-06-30 22:04:15
浏览次数:2
分类:技术文章
本文共 1822 字,大约阅读时间需要 6 分钟。
// ExitCodeRecv.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include#include /** 有个安装程序,安装结束(安装成功,安装失败)后, 会写一个.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#include #include 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
转载地址:https://lostspeed.blog.csdn.net/article/details/15804833 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月29日 17时46分43秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
leetcode 714 买卖股票的最佳时机含手续费
2019-04-30
leetcode3 无重复字符的最长子串
2019-04-30
leetcode 83. 删除排序链表中的重复元素
2019-04-30
Python 之 histogram直方图
2019-04-30
Python实现决策树 Desision Tree & 可视化
2019-04-30
决策树 Decision tree
2019-04-30
nominal和ordinal & 数据处理中四种基本数据类型
2021-07-03
Grid SearchCV(网格搜索)& Python实现
2021-07-03
单目深度估计 monodepth2模型 代码
2021-07-03
位图索引Bitmap indexes
2021-07-03
YOLO算法(二)—— Yolov2 & yolo9000
2021-07-03
计算机视觉中的cost-volume的概念具体指什么(代价体积)
2021-07-03
启发函数heuristic 与 A*
2021-07-03
Image Pyramid(图像金字塔)
2021-07-03
Oracle 作业记录
2021-07-03