C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  117 Posts :: 2 Stories :: 61 Comments :: 0 Trackbacks

常用链接

留言簿(8)

搜索

  •  

最新评论

阅读排行榜

评论排行榜

 

1、GetLastError()函数作用

      这个函数可以获得一个系统的错误代码,通过错误代码得到程序的问题所在,错误代码可以在MSDN上查到:System Errors - Numerical Order

2、代码参考

#include"stdafx.h"
#include
<windows.h>
#include
<stdio.h>
#include
<iostream>
using namespace std;
int main(int argc, char* argv[])
{
    unsigned 
short us=(unsigned short)6553658;
    
int errorcode=GetLastError();
    
char sz[100];
    sprintf(sz,
"error %d",errorcode);
    MessageBox(NULL,sz,
"Tip",MB_OK);
    
return 0;
}

       在函数调用、内存申请、数值计算时,在出错的地方尽量多调用GetLastError()

posted on 2010-01-29 20:06 烟皑 阅读(899) 评论(0)  编辑 收藏 引用 所属分类: 《Visual C++代码参考与技巧大全》学习笔记

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理