Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What As-clause argument for HRESULT?
Message
De
30/10/2001 08:26:11
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
29/10/2001 21:22:58
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00574850
Message ID:
00574957
Vues:
23
>I am going to revise the COM+ Events samples to test the actual operation of return codes from various simultaneous SUBSCRIBERS. I intend to revise the Event class itself to indicate that a return value is expected, then return with a value from the SUBSCRIBERs.
>I will revise the existing subscriber and add a near-duplicate of it, amending them both to sometimes return 'failed' under specific circumstances. It will be simple and one may fail or the other may fail or both may fail. When they fail I will return HRESULT of/for failed, otherwise I will return HRESULT of successful.
>
>Problem is, I can't figure out what to code as the function return type for HRESULT or what to actually return. For the return I'm inclined to return 0 for successful and a negative like -1 for failed.
>
>Can someone advise what I should code as both the right side of the "AS" clause for the function return type and the value (or whatever) to put into the actual RETURNs of the SUBSCRIBERS for SUCCESS and FAILED?
>
>Thanks
>Jim Nelson

Jim,
Any integer would do (0 as success). OLE return HRESULT as an integer where bit settings provide some more info, check winerror.h for details. This is froom winerror.h :
// The return value of OLE APIs and methods is an HRESULT.
// This is not a handle to anything, but is merely a 32-bit value
// with several fields encoded in the value.  The parts of an
// HRESULT are shown below.
//
// Many of the macros and functions below were orginally defined to
// operate on SCODEs.  SCODEs are no longer used.  The macros are
// still present for compatibility and easy porting of Win16 code.
// Newly written code should use the HRESULT macros and functions.
//

//
//  HRESULTs are 32 bit values layed out as follows:
//
//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
//  +-+-+-+-+-+---------------------+-------------------------------+
//  |S|R|C|N|r|    Facility         |               Code            |
//  +-+-+-+-+-+---------------------+-------------------------------+
//
//  where
//
//      S - Severity - indicates success/fail
//
//          0 - Success
//          1 - Fail (COERROR)
//
//      R - reserved portion of the facility code, corresponds to NT's
//              second severity bit.
//
//      C - reserved portion of the facility code, corresponds to NT's
//              C field.
//
//      N - reserved portion of the facility code. Used to indicate a
//              mapped NT status value.
//
//      r - reserved portion of the facility code. Reserved for internal
//              use. Used to indicate HRESULT values that are not status
//              values, but are instead message ids for display strings.
//
//      Facility - is the facility code
//
//      Code - is the facility's status code
//

//
// Severity values
//

#define SEVERITY_SUCCESS    0
#define SEVERITY_ERROR      1


//
// Generic test for success on any status value (non-negative numbers
// indicate success).
//

#define SUCCEEDED(Status) ((HRESULT)(Status) >= 0)

//
// and the inverse
//

#define FAILED(Status) ((HRESULT)(Status)<0)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform