博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
获取windows系统错误
阅读量:2387 次
发布时间:2019-05-10

本文共 709 字,大约阅读时间需要 2 分钟。

//Returns the last Win32 error, in string format. Returns an empty string if there is no error.#ifdef UNICODEstd::wstring GetSysError(DWORD errCode)#elsestd::string GetSysError(DWORD errCode)#endif{	DWORD errorMessageID = errCode;	TCHAR* messageBuffer = nullptr;	size_t size = FormatMessage(		FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,		NULL,		errorMessageID,		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),		(TCHAR *)&messageBuffer,		0,		NULL);#ifdef UNICODE	std::wstring message(messageBuffer, size);#else	std::string message(messageBuffer, size);#endif	//Free the buffer.	LocalFree(messageBuffer);	return message;

转载于:https://my.oschina.net/3cwYg4/blog/2987983

你可能感兴趣的文章
从头做leetcode之leetcode 25 K个一组翻转链表
查看>>
做leetcode过程中遇到heap-use-after-free问题的解决方法
查看>>
从头做leetcode之leetcode 26 删除排序数组中的重复项
查看>>
从头做leetcode之leetcode 27 移除元素
查看>>
从头做leetcode之leetcode 28 实现strStr()
查看>>
从头回顾C++基础(三)
查看>>
从头做leetcode之leetcode 29 两数相除
查看>>
从头做leetcode之leetcode 30 串联所有单词的子串
查看>>
从头做leetcode之leetcode 31 下一个排列
查看>>
从头做leetcode之leetcode 32 最长有效括号
查看>>
从头做leetcode之leetcode 33 搜索旋转排序数组
查看>>
从头做leetcode之leetcode 34 在排序数组中查找元素的值
查看>>
从头做leetcode之leetcode 35 搜索插入位置
查看>>
从头做leetcode之leetcode 36 有效的数独
查看>>
从头做leetcode之leetcode 37 解数独
查看>>
从头做leetcode之leetcode 39 组合总和
查看>>
从头做leetcode之leetcode 40 组合总数2
查看>>
从头做leetcode之leetcode 41 缺失的第一个正数
查看>>
从头做leetcode之leetcode 42 接雨水
查看>>
从头做leetcode之leetcode 43 字符串相乘
查看>>