Home > Software engineering >  WIN32, VC programming, capture software all exceptions of C source code
WIN32, VC programming, capture software all exceptions of C source code

Time:04-26

This article belong to "518 supermarket broadcasting software development log" part of the series,
I'm in the development of "518 supermarket broadcast software" (), have an exception capture demand, that is to say if the user is using pirated cracked and that may cause abnormal exit, software program finally to catch the exception, and prompt the user not to use pirate, development tools is VC2015,

code __try, __except
__try
{
if (! G_app. Init_app (bTray bLockWorkStation)) {
OleUninitialize ();
return 0;
}

MSG MSG.
HWND hLvPgmsA=GetDlgItem (g_app m_hPanelaA, IDC_panel_lvPgms);
HWND hLvPgmsB=GetDlgItem (g_app m_hPanelB, IDC_panel_lvPgms);
HACCEL hAccelA=LoadAccelerators (g_app m_hInst, LPCTSTR IDR_accelA);
HACCEL hAccelB=LoadAccelerators (g_app m_hInst, LPCTSTR IDR_accelB);
While (GetMessage (& amp; MSG, NULL, 0, 0))
{
Int independence idx=SendDlgItemMessage (g_app m_hLeft, IDC_left_list, LB_GETCURSEL, 0, 0).
If (independence idx==1 & amp; & G_app. M_iTabOfPanelA==0 & amp; & GetFocus ()==hLvPgmsA)
{
If (TranslateAccelerator (g_app m_hPanelaA hAccelA, & amp; MSG))
continue;
}
Else if (independence idx==2 & amp; & GetFocus ()==hLvPgmsB)
{
If (TranslateAccelerator (g_app m_hPanelB hAccelB, & amp; MSG))
continue;
}
TranslateMessage (& amp; MSG);
DispatchMessage (& amp; MSG);
}
}
The __except (1)
{
Disable_allPgms ();
WCHAR MSG={0} [MAX_MSG];
DWORD ec=GetExceptionCode ();
Swprintf (MSG, L "software exception (0 x % 08 x) common reasons: \ n \ n \ n for pirated software, Suggestions to the website to download software to reinstall \ n \ n if there is still a problem: \ n looking for technical support - website & gt; Contact us & gt; QQ/phone etc. \ n \ n points determine open website: nwww.518boyin.com \ ", ec);
MessageBox (g_app m_hMain, MSG, g_title, MB_OK | MB_ICONERROR | MB_TOPMOST | MB_SETFOREGROUND);
G_app. MyShellExecute (NULL, "open," L URL_HOME, NULL, NULL, SW_SHOWNORMAL);
}

VC2015 exception handling Settings

In the project properties, find out the inside of the c + + code generation,
1. Enable c + + exceptions: yes, but there is SEH exception/EHa
2. The security check: disable security check
3. Enable the floating-point exception: no
4. To enable the function level link: no/Gy -

CodePudding user response:

What your problem is