Click here to Skip to main content
15,888,461 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
Questionmfc Pin
shizhanbiao5-Nov-13 19:59
shizhanbiao5-Nov-13 19:59 
AnswerRe: mfc Pin
CPallini5-Nov-13 21:32
mveCPallini5-Nov-13 21:32 
QuestionRe: mfc Pin
David Crow6-Nov-13 4:13
David Crow6-Nov-13 4:13 
QuestionGetting output parameters value[Solved] Pin
pkfox4-Nov-13 4:04
professionalpkfox4-Nov-13 4:04 
SuggestionRe: Gettin output parameters value Pin
Richard MacCutchan4-Nov-13 6:10
mveRichard MacCutchan4-Nov-13 6:10 
GeneralRe: Gettin output parameters value Pin
pkfox4-Nov-13 10:07
professionalpkfox4-Nov-13 10:07 
SuggestionRe: Gettin output parameters value Pin
David Crow4-Nov-13 10:44
David Crow4-Nov-13 10:44 
GeneralRe: Gettin output parameters value Pin
Richard MacCutchan4-Nov-13 22:29
mveRichard MacCutchan4-Nov-13 22:29 
GeneralRe: Gettin output parameters value Pin
Richard MacCutchan4-Nov-13 22:31
mveRichard MacCutchan4-Nov-13 22:31 
GeneralRe: Gettin output parameters value Pin
pkfox5-Nov-13 20:00
professionalpkfox5-Nov-13 20:00 
GeneralRe: Gettin output parameters value Pin
Richard MacCutchan5-Nov-13 21:37
mveRichard MacCutchan5-Nov-13 21:37 
GeneralRe: Gettin output parameters value Pin
pkfox6-Nov-13 3:05
professionalpkfox6-Nov-13 3:05 

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.