Mea culpa...  I didn't pay enough attention to the OP's  description.

What I've read in the sources matches the documentation quoted by 
the OP - that [out] or [out,retval] parameters cause the HRESULT 
to be lost.

If the S_FALSE HRESULT can be taken to mean that any output 
parameters are invalid, it would be possible to adapt ctypes (not 
comtypes!) to raise an exception for S_FALSE.  To me, any HRESULTs 
that aren't S_OK should raise exceptions, but I'm sure there are cases 
out there where this would be problematic.

Creating a C/C++ extension (perhaps using Pyrex or Cython) to get 
the HRESULT  if the output parameters are valid for S_FALSE is 
the only other solution that occurs to me.

-------------------------> "These thoughts are mine alone!" <---------
Andrew MacIntyre           Operations Branch
tel:   +61 2 6219 5356     Communications Infrastructure Division
fax:   +61 2 6253 3277     Australian Communications & Media Authority
email: andrew.macint...@acma.gov.au            http://www.acma.gov.au/


> -----Original Message-----
> From: Michael Curran [mailto:m...@kulgan.net]
> Sent: Thursday, 14 January 2010 10:39 AM
> To: comtypes-users@lists.sourceforge.net
> Subject: Re: [comtypes-users] getting successful HRESULT values from
> comtypes [SEC=PERSONAL]
> 
> Hi,
> 
> If I understand correctly,  catching COM exceptions will not work in
> this case as  a return value of S_FALSE does not actually cause an
> exception.
> 
> Therefore it is impossible to be able to tell the difference between
> S_OK and S_FALSE.
> 
> Only the E_* values (specifically negative HRESULTS) cause an exception.
> 
> Mick
> 
> 
> 
> On 14/01/2010 10:05 AM, Andrew MacIntyre wrote:
> > Catch the COMError exception and inspect its attributes.
> >
> > -------------------------> "These thoughts are mine alone!" <---------
> >
> > Andrew MacIntyre Operations Branch
> >
> > tel: +61 2 6219 5356 Communications Infrastructure Division
> >
> > fax: +61 2 6253 3277 Australian Communications & Media Authority
> >
> > email: andrew.macint...@acma.gov.au
> > <mailto:andrew.macint...@acma.gov.au> http://www.acma.gov.au/
> >
> > *From:* Allen Saunders [mailto:allenmsaund...@gmail.com]
> > *Sent:* Thursday, 14 January 2010 7:23 AM
> > *To:* comtypes-users@lists.sourceforge.net
> > *Subject:* [comtypes-users] getting successful HRESULT values from
> comtypes
> >
> >     Calling COM methods is straightforward just like with other Python
> >     objects. They can be called with positional and named arguments.
> >
> >     Arguments marked [out] or [out, retval] in the IDL are returned from
> >     a sucessful method call, in a tuple if there is more than one. If no
> >     [out] or [out, retval] arguments are present, the HRESULT returned
> >     by the method call is returned. When [out] or [out, retval]
> >     arguments are returned from a sucessful call, the HRESULT value is lost.
> >
> >     If the COM method call fails, a COMError exception is raised,
> >     containing the HRESULT value.
> >
> > Is it true that there is no way to get a successful HRESULT from a call
> > that has [out] variables? An example is a function that can timeout, it
> > may return either S_OK (0) or S_FALSE (1), an the difference between the
> > two is important!
> >
> > Is there anyway for me to retrieve that 'lost' HRESULT?
> >
> > If you have received this email in error, please notify the sender
> > immediately and erase all copies of the email and any attachments to it.
> > The information contained in this email and any attachments may be
> > private, confidential and legally privileged or the subject of
> > copyright. If you are not the addressee it may be illegal to review,
> > disclose, use, forward, or distribute this email and/or its contents.
> >
> > Unless otherwise specified, the information in the email and any
> > attachments is intended as a guide only and should not be relied upon as
> > legal or technical advice or regarded as a substitute for legal or
> > technical advice in individual cases. Opinions contained in this email
> > or any of its attachments do not necessarily reflect the opinions of ACMA.
> >
> >
> >
> > ------------------------------------------------------------------------------
> > Throughout its 18-year history, RSA Conference consistently attracts the
> > world's best and brightest in the field, creating opportunities for
> Conference
> > attendees to learn about information security's most important issues
> through
> > interactions with peers, luminaries and emerging and established
> companies.
> > http://p.sf.net/sfu/rsaconf-dev2dev
> >
> >
> >
> > _______________________________________________
> > comtypes-users mailing list
> > comtypes-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/comtypes-users
> 
> --
> Michael Curran
> email/msn/jabber: m...@kulgan.net
> Skype/Twitter: md_curran
> 
> ------------------------------------------------------------------------------
> Throughout its 18-year history, RSA Conference consistently attracts the
> world's best and brightest in the field, creating opportunities for Conference
> attendees to learn about information security's most important issues
> through
> interactions with peers, luminaries and emerging and established companies.
> http://p.sf.net/sfu/rsaconf-dev2dev
> _______________________________________________
> comtypes-users mailing list
> comtypes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/comtypes-users

If you have received this email in error, please notify the sender immediately 
and erase all copies of the email and any attachments to it. The information 
contained in this email and any attachments may be private, confidential and 
legally privileged or the subject of copyright. If you are not the addressee it 
may be illegal to review, disclose, use, forward, or distribute this email 
and/or its contents.
 
Unless otherwise specified, the information in the email and any attachments is 
intended as a guide only and should not be relied upon as legal or technical 
advice or regarded as a substitute for legal or technical advice in individual 
cases. Opinions contained in this email or any of its attachments do not 
necessarily reflect the opinions of ACMA.

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to