惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Cloudflare Blog
T
Tenable Blog
V
Vulnerabilities – Threatpost
T
Troy Hunt's Blog
SecWiki News
SecWiki News
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Secure Thoughts
Cyberwarzone
Cyberwarzone
A
Arctic Wolf
H
Heimdal Security Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
N
News and Events Feed by Topic
The Hacker News
The Hacker News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cisco Talos Blog
Cisco Talos Blog
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
Forbes - Security
Forbes - Security
Security Archives - TechRepublic
Security Archives - TechRepublic
Project Zero
Project Zero
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
T
Tor Project blog
WordPress大学
WordPress大学
AWS News Blog
AWS News Blog
Jina AI
Jina AI
阮一峰的网络日志
阮一峰的网络日志
Cloudbric
Cloudbric
O
OpenAI News
U
Unit 42
Google DeepMind News
Google DeepMind News
Simon Willison's Weblog
Simon Willison's Weblog
Recorded Future
Recorded Future
N
News | PayPal Newsroom
S
Schneier on Security
F
Full Disclosure
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
P
Privacy International News Feed
L
LINUX DO - 最新话题
F
Fortinet All Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Recent Announcements
Recent Announcements

博客园 - 斌伯

【DX12龙书】第十一章 模板 顺序无关半透明资料 【DX12龙书】第十章 混合 【DX12龙书】第九章 纹理贴图 【DX12龙书】第八章 光照 【DX12龙书】第七章 利用Direct3D绘制几何体(续) 【DX12龙书】第六章 利用Direct3D绘制几何体 【DX12龙书】第五章 渲染管线 【DX12龙书】第四章 Direct3D的初始化 Godot开发环境与学习资源 源码开放的引擎研究 海龟交易法操作商品期货 重新开始 使用node_redis进行redis数据库crud操作 ACTGame项目 我所理解的网络游戏<?>:战斗逻辑设计 我所理解的网络游戏<一>:网游的顶层设计 《Real Time Rendering》第四章 图形变换 《程序员的自我修养》学习笔记(一):简介 《Real Time Rendering》第三章 图形处理单元 《TCP/IP协议详解》学习笔记(一):概述 《Windows via C/C++》学习笔记(二):Working with Characters and String 《Real Time Rendering》第二章 图形渲染管线 《Real Time Rendering》第三版 翻译
《Windows via C/C++》学习笔记(一):Error handling
斌伯 · 2012-09-15 · via 博客园 - 斌伯

1. 介绍了Windows函数的几种返回值:

类型

说明

VOID

函数不能失败

BOOL

函数失败时返回0;成功时返回非0。可测试是否为FALSE

HANDLE

函数失败时通常返回NULL(即0),亦有可能为INVALID_HANDLE_VALUE(即-1);成功则为相应的句柄

PVOID

函数失败时通常返回NULL(即0);成功则为数据块所在的内存地址

LONG/DWORD

函数失败时通常返回0或-1,具体参见Platform SDK文档

2. 相关函数

DWORD GetLastError() 

· 该函数通过线程局部存储Thread-local storage)机制获得线程当前的错误代号。

· 必须在Windows函数失败后立即调用该函数,否则其错误代号有可能被另一个函数调用结果所覆盖,Windows函数成功时调用GetLastError将返回ERROR_SUCCESS。

· 即使某个Windows函数运行成功,亦可通过GetLastError获得一些额外的信息。

· Visual studio可以在监视器上设置“$err,hr”监视GetLastError的返回值。

DWORD FormatMessage(

DWORD dwFlags,

LPCVOID pSource,

DWORD dwMessageId,

DWORD dwLanguageId,

PTSTR pszBuffer,

DWORD nSize,

Va_list *Arguments

);

· 该函数将错误代号转换为相应的文字表述。

· 支持多语言(dwLanguage)。

· 支持DLL导入(pSource)。

3. 自定义错误号

错误代号为一32位整形数,其第29位若为0则为微软定义的错误代号;为1则为雍和自定义,具体详见第二十四章。

posted @ 2012-09-15 18:34  斌伯  阅读(580)  评论()    收藏  举报