Click here to Skip to main content
15,889,867 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Extra bytes between struct elements spoiling match between structs and binary file formats: cure found Pin
Matthew Faithfull21-Dec-07 2:13
Matthew Faithfull21-Dec-07 2:13 
JokeIndeed... Pin
CPallini21-Dec-07 2:52
mveCPallini21-Dec-07 2:52 
JokeRe: Indeed... Pin
Matthew Faithfull21-Dec-07 3:04
Matthew Faithfull21-Dec-07 3:04 
GeneralRe: Indeed... Pin
CPallini21-Dec-07 3:15
mveCPallini21-Dec-07 3:15 
GeneralRe: Extra bytes between struct elements spoiling match between structs and binary file formats: cure found Pin
Mark Salsbery21-Dec-07 8:14
Mark Salsbery21-Dec-07 8:14 
Questionis such exception handling approach good? Pin
George_George21-Dec-07 1:42
George_George21-Dec-07 1:42 
AnswerRe: is such exception handling approach good? Pin
Matthew Faithfull21-Dec-07 2:05
Matthew Faithfull21-Dec-07 2:05 
QuestionThread using COleDispatchDriver always causes exception on second execution Pin
Streifenhoernchen21-Dec-07 1:42
Streifenhoernchen21-Dec-07 1:42 
In general, what the thread does is: Creating and sending an e-mail containing a file attachment using an Outlook or Lotus Notes client (if installed on the system).
Running the thread once always works fine, and it terminates correctly. However, when i try to run it for a second time, it throws an exception in MFC42.DLL, unfortunately not always at the same code line, but more or less randomly, esp. during manual debugging:

UINT CommonSendMailThread(LPVOID pParam)<br />
{<br />
   //pParam is a user-defined struct containing the necessary credentials<br />
   //like recipient address, file attachment path and name, and so on...<br />
<br />
   //a global variable sType defines the user's default mail client app<br />
   //user has "Outlook" as default<br />
   if (sType == "%OUTLOOK%") {<br />
      try {	<br />
         _DApplication OutlookHandle;	<br />
			<br />
         // Initialize OLE libraries<br />
         if (!AfxOleInit())<br />
            return 1;<br />
         else {   //try to find the installed version of Outlook<br />
            if (OutlookHandle.CreateDispatch("Outlook.Application.8") == FALSE) {<br />
               // check for Outlook 2000<br />
               if (OutlookHandle.CreateDispatch("Outlook.Application.9") == FALSE) {<br />
                  // check for Outlook XP<br />
                  if (OutlookHandle.CreateDispatch("Outlook.Application.10") == FALSE) {<br />
                     // Outlook ???<br />
                     if (OutlookHandle.CreateDispatch("Outlook.Application.11") == FALSE) {<br />
                        // Outlook ???????<br />
                        if (OutlookHandle.CreateDispatch("Outlook.Application.12") == FALSE) {<br />
                           return 1;<br />
         }}}}}}<br />
<br />
         // Outlook dispatch created successfully	<br />
         _DMailItem	newMail;<br />
<br />
         // create a new mail<br />
         newMail = OutlookHandle.CreateItem(0);<br />
<br />
         //fill the mail...<br />
         //(...)<br />
         //and send it			<br />
			<br />
         newMail.Send();<br />
<br />
         OutlookHandle.ReleaseDispatch();<br />
      }<br />
<br />
      catch(...) {<br />
         return 1;<br />
      }<br />
   } // OUTLOOK<br />
<br />
   //user has "Lotus Notes" as default<br />
   else if (sType == "%NOTES%") {<br />
      try {<br />
         if (!AfxOleInit())<br />
            return 1;<br />
<br />
         NOTESSESSION *pNotesSes = NULL;<br />
         NOTESDATABASE *pNotesDB = NULL;<br />
         NOTESDOCUMENT *pNotesDoc = NULL;<br />
         NOTESRICHTEXTITEM *pNotesRichTextItem = NULL;<br />
<br />
         // pointer to new NotesSession<br />
         pNotesSes = new NOTESSESSION;<br />
<br />
         if ( !pNotesSes )<br />
            return 1;<br />
<br />
         if ( pNotesSes == NULL )<br />
            return 1;<br />
<br />
         if (!pNotesSes -> CreateDispatch( "Notes.NotesSession" ))<br />
            return 1;<br />
	<br />
         if ( pNotesSes -> m_lpDispatch == NULL ) {		<br />
            delete pNotesSes;<br />
            return 1;<br />
         }<br />
<br />
         //Create and fill the mail...<br />
         //(...)<br />
			<br />
         pNotesDoc ->SEND(0, COleVariant(sRecipientAddress));<br />
         pNotesDoc ->REMOVE (0);<br />
<br />
         pNotesRichTextItem ->ReleaseDispatch();<br />
         pNotesDoc ->ReleaseDispatch();<br />
         pNotesDB ->ReleaseDispatch();<br />
         pNotesSes ->ReleaseDispatch();<br />
<br />
         delete pNotesRichTextItem;<br />
         delete pNotesDoc;<br />
         delete pNotesDB;<br />
         delete pNotesSes;<br />
      }<br />
<br />
      catch(...) {<br />
         return 1;<br />
      }<br />
   } // NOTES<br />
   else {<br />
      return 1;<br />
   }<br />
<br />
   //exit the thread<br />
   return 0;<br />
}


I'm totally confused and have no idea how to solve or even access the problem. Any hint or help is greatly appreciated!
GeneralRe: Thread using COleDispatchDriver always causes exception on second execution Pin
Nathan Holt at EMOM21-Dec-07 7:43
Nathan Holt at EMOM21-Dec-07 7:43 
GeneralSubclassing (using MFC) a wndow under explorer process Pin
Nishad S21-Dec-07 1:38
Nishad S21-Dec-07 1:38 
QuestionReference are always lvalue? Pin
George_George21-Dec-07 1:11
George_George21-Dec-07 1:11 
AnswerRe: Reference are always lvalue? Pin
Budric B.21-Dec-07 5:09
Budric B.21-Dec-07 5:09 
GeneralRe: Reference are always lvalue? Pin
George_George21-Dec-07 19:16
George_George21-Dec-07 19:16 
Questionhow to get the number of lines shown in editbox Pin
rajneshmalik21-Dec-07 1:06
rajneshmalik21-Dec-07 1:06 
AnswerRe: how to get the number of lines shown in editbox Pin
CPallini21-Dec-07 3:05
mveCPallini21-Dec-07 3:05 
GeneralDatashowing problem want to get rid of from if-else statement Pin
Y_Kaushik20-Dec-07 23:53
Y_Kaushik20-Dec-07 23:53 
GeneralRe: Datashowing problem want to get rid of from if-else statement Pin
Hamid_RT21-Dec-07 0:02
Hamid_RT21-Dec-07 0:02 
GeneralRe: Datashowing problem want to get rid of from if-else statement Pin
Cedric Moonen21-Dec-07 0:13
Cedric Moonen21-Dec-07 0:13 
GeneralRe: Datashowing problem want to get rid of from if-else statement Pin
Cedric Moonen21-Dec-07 0:11
Cedric Moonen21-Dec-07 0:11 
GeneralRe: Datashowing problem want to get rid of from if-else statement Pin
Matthew Faithfull21-Dec-07 0:11
Matthew Faithfull21-Dec-07 0:11 
GeneralRe: Datashowing problem want to get rid of from if-else statement Pin
Y_Kaushik21-Dec-07 19:08
Y_Kaushik21-Dec-07 19:08 
GeneralDynamically providing version information to a exe Pin
neha.agarwal2720-Dec-07 22:50
neha.agarwal2720-Dec-07 22:50 
GeneralRe: Dynamically providing version information to a exe Pin
jhwurmbach20-Dec-07 23:08
jhwurmbach20-Dec-07 23:08 
GeneralRe: Dynamically providing version information to a exe Pin
Chris Losinger21-Dec-07 5:45
professionalChris Losinger21-Dec-07 5:45 
GeneralChecking the camera is connecte or not Pin
Deepu Antony20-Dec-07 22:26
Deepu Antony20-Dec-07 22:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.