Click here to Skip to main content
15,912,205 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Future Of C++ Pin
Joe Woodbury11-Nov-13 6:01
professionalJoe Woodbury11-Nov-13 6:01 
GeneralRe: Future Of C++ Pin
Hadi11-Nov-13 9:17
Hadi11-Nov-13 9:17 
GeneralRe: Future Of C++ Pin
Joe Woodbury11-Nov-13 10:25
professionalJoe Woodbury11-Nov-13 10:25 
AnswerRe: Future Of C++ Pin
jschell11-Nov-13 8:14
jschell11-Nov-13 8:14 
QuestionCompiler On Linux Pin
Thong LeTrung8-Nov-13 16:51
Thong LeTrung8-Nov-13 16:51 
AnswerRe: Compiler On Linux Pin
Richard MacCutchan8-Nov-13 23:00
mveRichard MacCutchan8-Nov-13 23:00 
AnswerRe: Compiler On Linux Pin
Albert Holguin14-Nov-13 5:24
professionalAlbert Holguin14-Nov-13 5:24 
GeneralRe: Compiler On Linux Pin
Thong LeTrung16-Nov-13 20:25
Thong LeTrung16-Nov-13 20:25 
Questionvolatile local variable Pin
econy6-Nov-13 3:32
econy6-Nov-13 3:32 
AnswerRe: volatile local variable Pin
David Knechtges6-Nov-13 3:37
David Knechtges6-Nov-13 3:37 
GeneralRe: volatile local variable Pin
econy6-Nov-13 4:19
econy6-Nov-13 4:19 
GeneralRe: volatile local variable Pin
pasztorpisti6-Nov-13 4:23
pasztorpisti6-Nov-13 4:23 
GeneralRe: volatile local variable Pin
econy6-Nov-13 4:44
econy6-Nov-13 4:44 
GeneralRe: volatile local variable Pin
pasztorpisti6-Nov-13 5:15
pasztorpisti6-Nov-13 5:15 
GeneralRe: volatile local variable Pin
econy6-Nov-13 5:36
econy6-Nov-13 5:36 
GeneralRe: volatile local variable Pin
pasztorpisti6-Nov-13 5:39
pasztorpisti6-Nov-13 5:39 
GeneralRe: volatile local variable Pin
Aescleal6-Nov-13 4:49
Aescleal6-Nov-13 4:49 
GeneralRe: volatile local variable Pin
pasztorpisti6-Nov-13 5:09
pasztorpisti6-Nov-13 5:09 
AnswerRe: volatile local variable Pin
jschell6-Nov-13 8:03
jschell6-Nov-13 8:03 
Question_com_error not caught by 'Try-Catch' code Pin
Mike Grove5-Nov-13 22:14
Mike Grove5-Nov-13 22:14 
I have added some code (to an existing MFC/ATL application), to communicate with a piece of hardware that comes complete with com-based driver software.

(Before I forget: I'm writing C++ in Visual Studio 2010, for Windows7).

My code is based closely upon the sample code that the hardware manufacturer supplied, and is as follows;

C++
#import "GlobMgr.dll"	no_namespace // I/O funtionality
#import "IviDriverTypeLib.dll"	no_namespace // IVI inherent functionality
#import "agu265x.dll"	no_namespace // Instrument specific functionality

IAgilentU265xPtr spAgDrvrSlot1;

CCMDS::CCMDS( ...class details not relevant... )
  : CUSBDevice( ...ditto... )
{
  // Must first call either CoInitialize or CoInitializeEx to initialize COM **DON'T NEED THIS BIT - COM ALREADY INITIALISED**
  //HRESULT hr = S_OK;
  //hr = CoInitialize( NULL );
  //if ( hr != S_OK )
  //{
  //	if ( hr == S_FALSE )
  //	{
  //		AfxMessageBox( "Com Already Initialised" );
  //	}
  //	else
  //	{
  //		AfxMessageBox( "Co-initialise Failed" );
  //	}
  //}

  // Create and Initialise instances of the Agilent driver for
  // each of the four U2635A I/O modules in the U2781A rack
  spAgDrvrSlot1.CreateInstance( __uuidof( AgilentU265x ) );

  try
  {
	spAgDrvrSlot1->Initialize( "USBInstrument1", VARIANT_FALSE, VARIANT_TRUE, "" );
  }
  catch ( _com_error e )
  {
	AfxMessageBox( "Driver Initialise Failed" );
  }


HOWEVER, my code crashes at the Initialize(USBInstrument1...) statement with a Windows dialog saying
Quote:
First-chance exception at 0x755bb9bc in IOHandler.exe: Microsoft C++ exception: _com_error at memory location 0x001de4e0..

Why this code fails at all is a mystery but the big question is why does Windows crash with a dialog rather than my Try-Catch code catching the error in the controlled fashion I'd hoped for??
SuggestionRe: _com_error not caught by 'Try-Catch' code Pin
Richard MacCutchan5-Nov-13 22:26
mveRichard MacCutchan5-Nov-13 22:26 
GeneralRe: _com_error not caught by 'Try-Catch' code Pin
Mike Grove5-Nov-13 22:53
Mike Grove5-Nov-13 22:53 
AnswerRe: _com_error not caught by 'Try-Catch' code Pin
Aescleal5-Nov-13 22:36
Aescleal5-Nov-13 22:36 
GeneralRe: _com_error not caught by 'Try-Catch' code Pin
Mike Grove5-Nov-13 22:57
Mike Grove5-Nov-13 22:57 
GeneralRe: _com_error not caught by 'Try-Catch' code Pin
Aescleal5-Nov-13 23:38
Aescleal5-Nov-13 23:38 

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.