ExceptionErrorMessage - C++ Buil

2021-11-02  本文已影响0人  玄坴

C++ Builder 参考手册System::SysutilsExceptionErrorMessage


获取产生异常的错误信息,用于 ShowException 内部调用的函数

头文件:#include <System.SysUtils.hpp>
命名空间:System::Sysutils
函数原型:

int __fastcall ExceptionErrorMessage(System::TObject* ExceptObject, void * ExceptAddr, System::WideChar * Buffer, int Size);

参数:

返回值:


例:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    try
    {
        HANDLE hFile = CreateFile(L"D:\\Temp\\Hsuanlu.txt", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
        CheckOSError(GetLastError());
        CloseHandle(hFile);
    }
    catch(...)
    {
        TObject *pObj = System::ExceptObject();
        void *pAddr = System::ExceptAddr();
        System::WideChar pBuf[1024];
        ExceptionErrorMessage(pObj,pAddr,pBuf,1024);
        ShowMessage(pBuf);
    }
}

运行结果:

运行结果

相关:


C++ Builder 参考手册System::SysutilsExceptionErrorMessage

上一篇 下一篇

猜你喜欢

热点阅读