怎么用FORMATMESSAGE(50分)

  • 主题发起人 zhenghui
  • 开始时间
Z

zhenghui

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.ApplicationEvents1Exception(Sender: TObject;<br>&nbsp; E: Exception);<br>&nbsp; var<br>&nbsp; &nbsp;lpMsgBuf:pChar;<br>begin<br>&nbsp; lpMsgBuf:=StrAlloc(256*sizeof(char));<br>&nbsp; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_FROM_SYSTEM,<br>&nbsp; &nbsp; Nil,<br>&nbsp; &nbsp; GetLastError(),<br>&nbsp; &nbsp; 86,//MAKELANGID(LANG_NEUTRAL,SUBLANG_SYS_DEFAULT), // Default language<br>&nbsp; &nbsp; lpMsgBuf,<br>&nbsp; &nbsp; 0,<br>&nbsp; &nbsp; Nil);<br><br>&nbsp; if lpMsgBuf&lt;&gt;NIl then<br>&nbsp; &nbsp; form1.Caption:=String(lpMsgBuf);<br><br>&nbsp; StrDispose(lpMsgBuf);<br><br><br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; image1.Picture.LoadFromFile('d:/a.bmp');//不存在该图片文件<br>end;<br>由于MAKELANGID(LANG_NEUTRAL,SUBLANG_SYS_DEFAULT), // Default language<br>是宏,DELPHI不能引用,0也不能用,我的错误提示代码提示出来的是乱码与GETLASTERROR<br>不符合<br>
 
MAKELANGID(LANG_NEUTRAL,SUBLANG_SYS_DEFAULT), <br>可以写成:<br>((SUBLANG_SYS_DEFAULT shl 10) or LANG_NEUTRAL)<br>
 
能解释一下吗,谢谢
 
还是不行
 
用GETLASTERROR返回值是2,用VC的ERROR LOOKUP返回系统找不到制定文件<br>跟实际情况一样,就是翻译不过来
 
接受答案了.
 
顶部