[shell-coding] Re: try() catch()
- From: "Donelle Sanders" <donelle_sanders@xxxxxxxxxxx>
- To: shell-coding@xxxxxxxxxxxxx
- Date: Tue, 21 Jan 2003 15:00:39 +0000
In regards to your question about object unwinding, you cannot use __try in functions that require object unwinding , with /GX switch a function with structured exception handling cannot have objects that require unwinding (destruction). This is what I was refering to when you asked about the try statement , sorry for not explaining more when I responded , my mistake ;) . I did a little research and what I found here: http://msdn.microsoft.com/library/default.asp?url=""> was very helpful. What I would do for your try/catch statment :
Try
{
?
throw IError;
}catch (IError e)
{
TCHAR tzError[MAX_LINE_LENGTH];
If (e.LoadString (IDS_MODULEINITEXCEPTION_ERROR, tzError,MAX_LINE_LENGTH)){
StringCchPrintf(tzErrorEx, MAX_LINE_LENGTH, tzError, iter->first.c_str());
e.MessageBox(NULL, tzErrorEx, IDS_LITESTEP_TITLE_ERROR);
}
}
I hoped this helped some..
-Matrice64
>From: Bgvinyard@xxxxxxx
>Reply-To: shell-coding@xxxxxxxxxxxxx
>To: shell-coding@xxxxxxxxxxxxx
>Subject: [shell-coding] try() catch()
>Date: Mon, 20 Jan 2003 21:20:09 EST
>
>Ok... im not too sure on this so thought i would get some expert help...
>
>given this:
>
>class Localization
>{
>public:
> Localization();
> ~Localization();
>
> void LoadLanguage(LANGID wLanguageID);
> int LoadString(UINT uID, LPTSTR ptzBuffer, size_t cchMax);
> int MessageBox(HWND hWnd, UINT uText, UINT uCaption, UINT uType);
> int MessageBox(HWND hWnd, LPCTSTR ptzText, UINT uCaption, UINT
>uType);
>
>private:
> HINSTANCE m_hRes;
> LANGID m_wLanguageID;
>};
>
>I want to do something like this:
>
>try
>{
> ...
>}
>catch(...)
>{
> TCHAR tzError[MAX_LINE_LENGTH];
> Localization lError;
>
> if (lError.LoadString(IDS_MODULEINITEXCEPTION_ERROR, tzError,
>MAX_LINE_LENGTH))
> {
> TCHAR tzErrorEx[MAX_LINE_LENGTH];
> StringCchPrintf(tzErrorEx, MAX_LINE_LENGTH, tzError, iter->
>first.c_str());
> lError.MessageBox(NULL, tzErrorEx, IDS_LITESTEP_TITLE_ERROR);
> }
>}
>
>I'm not sure this would affect object unwinding because its withing the catch
>block, unless
>the code within the catch block throws an exception... any comments?
>suggestions?
>
>Thanks
>Message
The new MSN 8 is here: Try it free* for 2 months
__________________________________________________
Subscription options and archive:
http://www.freelists.org/list/shell-coding
Other related posts:
- » [shell-coding] try() catch()
- » [shell-coding] Re: try() catch()
- » [shell-coding] Re: try() catch()
- » [shell-coding] Re: try() catch()
In regards to your question about object unwinding, you cannot use __try in functions that require object unwinding , with /GX switch a function with structured exception handling cannot have objects that require unwinding (destruction). This is what I was refering to when you asked about the try statement , sorry for not explaining more when I responded , my mistake ;) . I did a little research and what I found here: http://msdn.microsoft.com/library/default.asp?url=""> was very helpful. What I would do for your try/catch statment :
Try
{
?
throw IError;
}catch (IError e)
{
TCHAR tzError[MAX_LINE_LENGTH];
If (e.LoadString (IDS_MODULEINITEXCEPTION_ERROR, tzError,MAX_LINE_LENGTH)){
StringCchPrintf(tzErrorEx, MAX_LINE_LENGTH, tzError, iter->first.c_str());
e.MessageBox(NULL, tzErrorEx, IDS_LITESTEP_TITLE_ERROR);
}
}
I hoped this helped some..
-Matrice64