Get line number of error in c++ program

I have a C++ program that I want to trap errors in.
I have added the __try and __except code, but can't get what I want.

In the __except error handler, the GetExceptionInformation/ExceptionAddress contains....

0x00007ff6ce45c72b {Regshot-x64-ANSI-dbg.exe!LoadSettingsFromIni(HWND__ * hDlg), Line 200}

How do I get LINE 200 out of it?

I have code that gets Regshot-x64-ANSI-dbg.exe, but I already know the program name.
The code is...
std::string getModuleNameFrom2(LPCVOID pExcptAddr)
char szOffender[MAX_PATH] = { "_unknown_" };
VirtualQuery(pExcptAddr, &memInfo, sizeof(MAX_PATH)); // testing...

if ( VirtualQuery(pExcptAddr, &memInfo, sizeof(memInfo)) )
GetModuleFileName(memInfo.AllocationBase ? (HMODULE)memInfo.AllocationBase : GetModuleHandle(NULL), szOffender, MAX_PATH);
char *pszLast = strrchr(szOffender, '\\');
return std::string(pszLast ? pszLast + 1 : szOffender);
and it is called with:
sprintf(outline+rc, "FAULT: 0x%p %s\n", pExceptionAddr, getModuleNameFrom2pExceptionAddr).c_str());

Please send sample code to

Topic archived. No new replies allowed.