hbole

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  
c:\harbour\contrib\hbole
ole2.c
TypeFunctionSourceLine
STATIC DOUBLEDateToDbl( LPSTR cDate )
static double DateToDbl( LPSTR cDate )
{
   return hb_dateEncStr( cDate ) - 0x0024d9abL;
}
ole2.c103
STATIC LPSTRDblToDate( double nDate, char * cDate )
static LPSTR DblToDate( double nDate, char * cDate )
{
   hb_dateDecStr( cDate, ( long ) nDate + 0x0024d9abL );

   return cDate;
}
ole2.c108
STATIC LPWSTRAnsiToWide( LPCSTR cAnsi )
static LPWSTR AnsiToWide( LPCSTR cAnsi )
{
   unsigned int wLen;
   LPWSTR cString;

   wLen = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, cAnsi, -1, 0, 0 );
   cString = ( LPWSTR ) hb_xgrab( wLen * 2 );
   MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, cAnsi, -1,
                        ( LPWSTR ) cString, wLen );
   return cString;
}
ole2.c115
STATIC LPSTRWideToAnsi( LPWSTR cWide )
static LPSTR WideToAnsi( LPWSTR cWide )
{
   unsigned int wLen;
   LPSTR cString;

   wLen = WideCharToMultiByte( CP_ACP, 0, ( LPWSTR ) cWide, -1,
                               NULL, 0, NULL, NULL );
   cString = ( LPSTR ) hb_xgrab( wLen ? wLen : 2 );
   WideCharToMultiByte( CP_ACP, 0, ( LPWSTR ) cWide, -1,
                        cString, wLen, NULL, NULL );
   return cString;
}
ole2.c127
STATIC VOIDGetParams( DISPPARAMS * dParams )
static void GetParams( DISPPARAMS * dParams )
{
   VARIANTARG * pArgs = NULL;
   int n, nArgs, nArg;

   nArgs = hb_pcount() - 2;

   if( nArgs > 0 )
   {
      pArgs = ( VARIANTARG * ) hb_xgrab( sizeof( VARIANTARG ) * nArgs );

      for( n = 0; n < nArgs; n++ )
      {
         PHB_ITEM uParam;

         /* Los parametros en VARIANTARG[] hay que ponerlos en orden inverso */
         nArg = nArgs + 2 - n;

         VariantInit( &( pArgs[ n ] ) );

         uParam = hb_param( nArg, 0xFFFF );

         switch( hb_itemType( uParam ) )
         {
            case '\0':
#if !defined(__BORLANDC__) && !defined(__XCC__) && !defined(NONAMELESSUNION)
               pArgs[ n ].vt = VT_EMPTY;
#else
               pArgs[ n ].n1.n2.vt = VT_EMPTY;
#endif
               break;

            case HB_IT_STRING:
            case HB_IT_MEMO:
            {
               LPWSTR cString;

#if !defined(__BORLANDC__) && !defined(__XCC__) && !defined(NONAMELESSUNION)
               pArgs[ n ].vt = VT_BSTR;
#else
               pArgs[ n ].n1.n2.vt = VT_BSTR;
#endif
               cString = AnsiToWide( hb_parc( nArg ) );
#if !defined(__BORLANDC__) && !defined(__XCC__) && !defined(NONAMELESSUNION)
               pArgs[ n ].bstrVal = SysAllocString( ( OLECHAR * ) cString );
#else
               pArgs[ n ].n1.n2.n3.bstrVal = SysAllocString( ( OLECHAR * ) cString );
#endif
               hb_xfree( cString );
               break;
            }
            case HB_IT_LOGICAL:
#if !defined(__BORLANDC__) && !defined(__XCC__) && !defined(NONAMELESSUNION)
               pArgs[ n ].vt = VT_BOOL;
               pArgs[ n ].boolVal = hb_parl( nArg ) ? VARIANT_TRUE : VARIANT_FALSE;
#else
               pArgs[ n ].n1.n2.vt   = VT_BOOL;
               pArgs[ n ].n1.n2.n3.boolVal = hb_parl( nArg ) ? VARIANT_TRUE : VARIANT_FALSE;
#endif
               break;

            case HB_IT_INTEGER:
            case HB_IT_LONG:
            case HB_IT_NUMERIC:
#if !defined(__BORLANDC__) && !defined(__XCC__) && !defined(NONAMELESSUNION)
               pArgs[ n ].vt = VT_I4;
               pArgs[ n ].lVal = hb_parnl( nArg );
#else
               pArgs[ n ].n1.n2.vt = VT_I4;
               pArgs[ n ].n1.n2.n3.lVal = hb_parnl( nArg );
#endif
               break;

            case HB_IT_DOUBLE:
#if !defined(__BORLANDC__) && !defined(__XCC__) && !defined(NONAMELESSUNION)
               pArgs[ n ].vt = VT_R8;
               pArgs[ n ].dblVal = hb_parnd( nArg );
#else
               pArgs[ n ].n1.n2.vt = VT_R8;
               pArgs[ n ].n1.n2.n3.dblVal = hb_parnd( nArg );
#endif
               break;
            case HB_IT_DATE:
#if !defined(__BORLANDC__) && !defined(__XCC__) && !defined(NONAMELESSUNION)
               pArgs[ n ].vt = VT_DATE;
               pArgs[ n ].dblVal = DateToDbl( hb_pards( nArg ) );
#else
               pArgs[ n ].n1.n2.vt = VT_DATE;
               pArgs[ n ].n1.n2.n3.dblVal = DateToDbl( hb_pards( nArg ) );
#endif
               break;

            case HB_IT_OBJECT:
            {
               PHB_DYNS pData;
#if !defined(__BORLANDC__) && !defined(__XCC__) && !defined(NONAMELESSUNION)
               pArgs[ n ].vt = VT_EMPTY;
#else
               pArgs[ n ].n1.n2.vt = VT_EMPTY;
#endif
               if( hb_stricmp( hb_objGetClsName( uParam ), "TOleAuto" ) == 0 )
               {
                  pData = hb_dynsymFindName( "hObj" );
                  if( pData )
                  {
                     hb_vmPushDynSym( pData );
                     hb_vmPush( uParam );
                     hb_vmDo( 0 );
#if !defined(__BORLANDC__) && !defined(__XCC__) && !defined(NONAMELESSUNION)
                     pArgs[ n ].vt = VT_DISPATCH;
                     pArgs[ n ].pdispVal = ( IDispatch * ) hb_parptr( -1 );
#else
                     pArgs[ n ].n1.n2.vt = VT_DISPATCH;
                     pArgs[ n ].n1.n2.n3.pdispVal = ( IDispatch * ) hb_parptr( -1 );
#endif
                  }
               }
            }
            break;
         }
      }
   }

   dParams->rgvarg = pArgs;
   dParams->cArgs  = nArgs;
   dParams->rgdispidNamedArgs = 0;
   dParams->cNamedArgs = 0;
}
ole2.c140
STATIC VOIDFreeParams( DISPPARAMS * dParams )
static void FreeParams( DISPPARAMS * dParams )
{
   if( dParams->cArgs > 0 )
   {
      int n;

      for( n = 0; n < ( int ) dParams->cArgs; n++ )
         VariantClear( &( dParams->rgvarg[ n ] ) );

      hb_xfree( ( LPVOID ) dParams->rgvarg );
   }
}
ole2.c269
STATIC VOIDRetValue( void )
static void RetValue( void )
{
#if !defined(__BORLANDC__) && !defined(__XCC__) && !defined(NONAMELESSUNION)
   switch( s_RetVal.vt )
   {
      case VT_BSTR:
         hb_retc_buffer( WideToAnsi( ( LPSTR ) s_RetVal.bstrVal ) );
         break;

      case VT_BOOL:
         hb_retl( s_RetVal.boolVal == VARIANT_TRUE );
         break;

      case VT_DISPATCH:
         hb_retptr( s_RetVal.pdispVal );
         break;

      case VT_I4:
         hb_retnl( ( LONG ) s_RetVal.iVal );
         break;

      case VT_R8:
         hb_retnd( s_RetVal.dblVal );
         break;

      case VT_DATE:
      {
         char cDate[ 9 ];
         hb_retds( DblToDate( s_RetVal.dblVal, cDate ) );
         break;
      }
      case VT_EMPTY:
         break;

      default:
         if( s_nOleError == S_OK )
            s_nOleError = ( HRESULT ) -1;
           break;
   }

   if( s_RetVal.vt != VT_DISPATCH )
      VariantClear( &s_RetVal );
#else
   switch( s_RetVal.n1.n2.vt )
   {
      case VT_BSTR:
         hb_retc_buffer( WideToAnsi( ( LPWSTR ) s_RetVal.n1.n2.n3.bstrVal ) );
         break;

      case VT_BOOL:
         hb_retl( s_RetVal.n1.n2.n3.boolVal == VARIANT_TRUE );
         break;

      case VT_DISPATCH:
         hb_retptr( s_RetVal.n1.n2.n3.pdispVal );
         break;

      case VT_I4:
         hb_retnl( ( LONG ) s_RetVal.n1.n2.n3.iVal );
         break;

      case VT_R8:
         hb_retnd( s_RetVal.n1.n2.n3.dblVal );
         break;

      case VT_DATE:
      {
         char cDate[ 9 ];
         hb_retds( DblToDate( s_RetVal.n1.n2.n3.dblVal, cDate ) );
         break;
      }
      case VT_EMPTY:
         break;

      default:
         if( s_nOleError == S_OK )
            s_nOleError = ( HRESULT ) -1;
         break;
   }

   if( s_RetVal.n1.n2.vt != VT_DISPATCH )
      VariantClear( &s_RetVal );
#endif
}
ole2.c282
HB_FUNCCREATEOLEOBJECT(void)
HB_FUNC( CREATEOLEOBJECT ) /* ( cOleName | cCLSID  [, cIID ] ) */
{
   void * pDisp = NULL; /* IDispatch */
   /* 'void *' used intentionally to inform compiler that there is no strict-aliasing */

   s_nOleError = S_OK;

   if( ! s_bInitialized )
   {
      s_nOleError = OleInitialize( NULL );
      s_bInitialized = TRUE;
   }

   if( s_nOleError == S_OK || 
       s_nOleError == S_FALSE )
   {
      LPWSTR cCLSID;
      GUID ClassID, iid;
      LPIID riid = ( LPIID ) &IID_IDispatch;

      cCLSID = AnsiToWide( hb_parc( 1 ) );
      if( hb_parc( 1 )[ 0 ] == '{' )
         s_nOleError = CLSIDFromString( ( LPOLESTR ) cCLSID, ( LPCLSID ) &ClassID );
      else
         s_nOleError = CLSIDFromProgID( ( LPCOLESTR ) cCLSID, ( LPCLSID ) &ClassID );
      hb_xfree( cCLSID );

      if( hb_pcount() == 2 )
      {
         if( hb_parc( 2 )[ 0 ] == '{' )
         {
            cCLSID = AnsiToWide( hb_parc( 2 ) );
            s_nOleError = CLSIDFromString( ( LPOLESTR ) cCLSID, &iid );
            hb_xfree( cCLSID );
         }
         else
            memcpy( ( LPVOID ) &iid, hb_parc( 2 ), sizeof( iid ) );

         riid = &iid;
      }

      if( s_nOleError == S_OK )
         s_nOleError = CoCreateInstance( HB_ID_REF( REFCLSID, ClassID ), NULL, CLSCTX_SERVER,
                                         (REFIID) riid, &pDisp );
   }

   hb_retptr( pDisp );
}
ole2.c368
STATIC LPSTRhb_oleWideToAnsi( BSTR wString )
static LPSTR hb_oleWideToAnsi( BSTR wString )
{
   int nConvertedLen = WideCharToMultiByte( CP_ACP, 0, wString, -1, NULL, 0, NULL, NULL );

   if( nConvertedLen )
   {
      char * cString = ( char * ) hb_xgrab( nConvertedLen + 1 );

      if( WideCharToMultiByte( CP_ACP, 0, wString, -1, cString, nConvertedLen + 1, NULL, NULL ) )
         return cString;
      else
         hb_xfree( cString );
   }

   return NULL;
}
ole2.c417
HB_FUNCOLEEXCEPTIONSOURCE(void)
HB_FUNC( OLEEXCEPTIONSOURCE )
{
   if( ( LONG ) s_nOleError == DISP_E_EXCEPTION )
      hb_retc_buffer( hb_oleWideToAnsi( s_excep.bstrSource ) );
}
ole2.c434
HB_FUNCOLEEXCEPTIONDESCRIPTION(void)
HB_FUNC( OLEEXCEPTIONDESCRIPTION )
{
   if( ( LONG ) s_nOleError == DISP_E_EXCEPTION )
      hb_retc_buffer( hb_oleWideToAnsi( s_excep.bstrDescription ) );
}
ole2.c440
HB_FUNCOLEINVOKE(void)
HB_FUNC( OLEINVOKE ) /* ( hOleObject, szMethodName, uParams... ) */
{
   IDispatch * pDisp = ( IDispatch * ) hb_parptr( 1 );
   LPWSTR cMember;
   DISPID lDispID;
   DISPPARAMS dParams;
   UINT uArgErr;

   VariantInit( &s_RetVal );
   memset( ( LPBYTE ) &s_excep, 0, sizeof( s_excep ) );

   cMember = AnsiToWide( hb_parc( 2 ) );
   s_nOleError = pDisp->lpVtbl->GetIDsOfNames( pDisp, HB_ID_REF( REFIID, IID_NULL ),
                                               ( wchar_t ** ) &cMember, 1,
                                               LOCALE_USER_DEFAULT, &lDispID );
   hb_xfree( cMember );

   if( s_nOleError == S_OK )
   {
      GetParams( &dParams );
      s_nOleError = pDisp->lpVtbl->Invoke( pDisp,
                                           lDispID,
                                           HB_ID_REF( REFIID, IID_NULL ),
                                           LOCALE_USER_DEFAULT,
                                           DISPATCH_METHOD,
                                           &dParams,
                                           &s_RetVal,
                                           &s_excep,
                                           &uArgErr ) ;
      FreeParams( &dParams );
   }

   RetValue();
}
ole2.c446
HB_FUNCOLESETPROPERTY(void)
HB_FUNC( OLESETPROPERTY ) /* ( hOleObject, cPropName, uValue, uParams... ) */
{
   IDispatch * pDisp = ( IDispatch * ) hb_parptr( 1 );
   LPWSTR cMember;
   DISPID lDispID;
   DISPID lPropPut = DISPID_PROPERTYPUT;
   DISPPARAMS dParams;
   UINT uArgErr;

   VariantInit( &s_RetVal );
   memset( ( LPBYTE ) &s_excep, 0, sizeof( s_excep ) );

   cMember = AnsiToWide( hb_parc( 2 ) );

   s_nOleError = pDisp->lpVtbl->GetIDsOfNames( pDisp, HB_ID_REF( REFIID, IID_NULL ),
                                               ( wchar_t ** ) &cMember, 1,
                                               LOCALE_USER_DEFAULT, &lDispID );

   hb_xfree( cMember );

   if( s_nOleError == S_OK )
   {
      GetParams( &dParams );
      dParams.rgdispidNamedArgs = &lPropPut;
      dParams.cNamedArgs = 1;

      s_nOleError = pDisp->lpVtbl->Invoke( pDisp,
                                           lDispID,
                                           HB_ID_REF( REFIID, IID_NULL ),
                                           LOCALE_USER_DEFAULT,
                                           DISPATCH_PROPERTYPUT,
                                           &dParams,
                                           NULL,    /* No return value */
                                           &s_excep,
                                           &uArgErr );

      FreeParams( &dParams );
   }
}
ole2.c481
HB_FUNCOLEGETPROPERTY(void)
HB_FUNC( OLEGETPROPERTY ) /* ( hOleObject, cPropName, uParams... ) */
{
   IDispatch * pDisp = ( IDispatch * ) hb_parptr( 1 );
   LPWSTR cMember;
   DISPID lDispID;
   DISPPARAMS dParams;
   UINT uArgErr;

   VariantInit( &s_RetVal );
   memset( ( LPBYTE ) &s_excep, 0, sizeof( s_excep ) );

   cMember = AnsiToWide( hb_parc( 2 ) );

   s_nOleError = pDisp->lpVtbl->GetIDsOfNames( pDisp, HB_ID_REF( REFIID, IID_NULL ),
                                               ( wchar_t ** ) &cMember, 1,
                                               LOCALE_USER_DEFAULT, &lDispID );
   hb_xfree( cMember );

   if( s_nOleError == S_OK )
   {
      GetParams( &dParams );
      s_nOleError = pDisp->lpVtbl->Invoke( pDisp,
                                           lDispID,
                                           HB_ID_REF( REFIID, IID_NULL ),
                                           LOCALE_USER_DEFAULT,
                                           DISPATCH_PROPERTYGET,
                                           &dParams,
                                           &s_RetVal,
                                           &s_excep,
                                           &uArgErr );

      FreeParams( &dParams );
   }

   RetValue();
}
ole2.c521
HB_FUNCOLEERROR(void)
HB_FUNC( OLEERROR )
{
   hb_retnl( ( long ) s_nOleError );
}
ole2.c558
HB_FUNCOLE2TXTERROR(void)
HB_FUNC( OLE2TXTERROR )
{
   switch( ( LONG ) s_nOleError )
   {
      case S_OK:                      hb_retc( "S_OK" );                    break;
      case CO_E_CLASSSTRING:          hb_retc( "CO_E_CLASSSTRING" );        break;
      case OLE_E_WRONGCOMPOBJ:        hb_retc( "OLE_E_WRONGCOMPOBJ" );      break;
      case REGDB_E_CLASSNOTREG:       hb_retc( "REGDB_E_CLASSNOTREG" );     break;
      case REGDB_E_WRITEREGDB:        hb_retc( "REGDB_E_WRITEREGDB" );      break;
      case E_OUTOFMEMORY:             hb_retc( "E_OUTOFMEMORY" );           break;
      case E_INVALIDARG:              hb_retc( "E_INVALIDARG" );            break;
      case E_UNEXPECTED:              hb_retc( "E_UNEXPECTED" );            break;
      case DISP_E_UNKNOWNNAME:        hb_retc( "DISP_E_UNKNOWNNAME" );      break;
      case DISP_E_UNKNOWNLCID:        hb_retc( "DISP_E_UNKNOWNLCID" );      break;
      case DISP_E_BADPARAMCOUNT:      hb_retc( "DISP_E_BADPARAMCOUNT" );    break;
      case DISP_E_BADVARTYPE:         hb_retc( "DISP_E_BADVARTYPE" );       break;
      case DISP_E_EXCEPTION:          hb_retc( "DISP_E_EXCEPTION" );        break;
      case DISP_E_MEMBERNOTFOUND:     hb_retc( "DISP_E_MEMBERNOTFOUND" );   break;
      case DISP_E_NONAMEDARGS:        hb_retc( "DISP_E_NONAMEDARGS" );      break;
      case DISP_E_OVERFLOW:           hb_retc( "DISP_E_OVERFLOW" );         break;
      case DISP_E_PARAMNOTFOUND:      hb_retc( "DISP_E_PARAMNOTFOUND" );    break;
      case DISP_E_TYPEMISMATCH:       hb_retc( "DISP_E_TYPEMISMATCH" );     break;
      case DISP_E_UNKNOWNINTERFACE:   hb_retc( "DISP_E_UNKNOWNINTERFACE" ); break;
      case DISP_E_PARAMNOTOPTIONAL:   hb_retc( "DISP_E_PARAMNOTOPTIONAL" ); break;
      default:                        hb_retc( "Unknown error" );           break;
   }
}
ole2.c563
HB_FUNCOLEISOBJECT(void)
HB_FUNC( OLEISOBJECT )
{
#if !defined(__BORLANDC__) && !defined(__XCC__) && !defined(NONAMELESSUNION)
   hb_retl( s_RetVal.vt == VT_DISPATCH );
#else
   hb_retl( s_RetVal.n1.n2.vt == VT_DISPATCH );
#endif
}
ole2.c591
HB_FUNCOLEUNINITIALIZE(void)
HB_FUNC( OLEUNINITIALIZE )
{
   if( s_bInitialized )
   {
      OleUninitialize();
      s_bInitialized = FALSE;
   }
}
ole2.c600
HB_FUNCGETOLEOBJECT(void)
HB_FUNC( GETOLEOBJECT )
{
   BSTR wCLSID;
   IID ClassID, iid;
   LPIID riid = ( LPIID ) &IID_IDispatch;
   IUnknown * pUnk = NULL;
   char * cOleName = hb_parc( 1 );
   void * pDisp = NULL; /* IDispatch */
   /* 'void *' used intentionally to inform compiler that there is no strict-aliasing */

   s_nOleError = S_OK;

   wCLSID = ( BSTR ) AnsiToWide( ( LPSTR ) cOleName );

   if( cOleName[ 0 ] == '{' )
      s_nOleError = CLSIDFromString( wCLSID, ( LPCLSID ) &ClassID );
   else
      s_nOleError = CLSIDFromProgID( wCLSID, ( LPCLSID ) &ClassID );

   hb_xfree( wCLSID );

   if( hb_pcount() == 2 )
   {
      char * cID = hb_parc( 2 );
      if( cID[ 0 ] == '{' )
      {
         wCLSID = ( BSTR ) AnsiToWide( ( LPSTR ) cID );
         s_nOleError = CLSIDFromString( wCLSID, &iid );
         hb_xfree( wCLSID );
      }
      else
         memcpy( ( LPVOID ) &iid, cID, sizeof( iid ) );

      riid = &iid;
   }

   if( s_nOleError == S_OK )
   {
      s_nOleError = GetActiveObject( HB_ID_REF( REFCLSID, ClassID ), NULL, &pUnk );

      if( s_nOleError == S_OK )
         s_nOleError = pUnk->lpVtbl->QueryInterface( pUnk, ( REFIID ) riid, &pDisp );
   }

   hb_retptr( pDisp );
}
ole2.c609
HB_FUNCMESSAGEBOX(void)
HB_FUNC( MESSAGEBOX )
{
   LPTSTR lpStr1 = HB_TCHAR_CONVTO( hb_parcx( 2 ) );
   LPTSTR lpStr2 = HB_TCHAR_CONVTO( hb_parcx( 3 ) );
   HWND hWnd = ISNUM( 1 ) ? ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ) :
                            ( HWND ) hb_parptr( 1 );
   hb_retni( MessageBox( hWnd, lpStr1, lpStr2, hb_parni( 4 ) ) );
   HB_TCHAR_FREE( lpStr1 );
   HB_TCHAR_FREE( lpStr2 );
}
ole2.c656
oleauto.prg
TypeFunctionSourceLine
CLASSTOleAuto
CLASS TOleAuto

   DATA hObj

   METHOD New( cAutoObj ) CONSTRUCTOR
   METHOD GetActiveObject( cClass )
   METHOD End()

   METHOD Invoke( cMember, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 )
   METHOD Set( cProperty, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 )
   METHOD Get( cProperty, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 )
   
   ERROR HANDLER OnError( cMsg, nError )

ENDCLASS
oleauto.prg60
STATIC PROCEDURETHROW( oError )
STATIC PROCEDURE THROW( oError )
   LOCAL lError := Eval( ErrorBlock(), oError )
   IF !HB_ISLOGICAL( lError ) .OR. lError
      __ErrInHandler()
   ENDIF
   Break( oError )
RETURN
oleauto.prg78
TOLEAUTO:METHODNew( uObj ) CLASS TOleAuto
METHOD New( uObj ) CLASS TOleAuto
   LOCAL oErr

   IF ISCHARACTER( uObj )
      ::hObj := CreateOleObject( uObj )
   ELSE
      ::hObj := uObj
   ENDIF

   IF Empty( ::hObj )
       oErr := ErrorNew()
       oErr:Args          := hb_AParams()
       oErr:CanDefault    := .F.
       oErr:CanRetry      := .F.
       oErr:CanSubstitute := .T.
       oErr:Description   := Ole2TxtError()
       oErr:GenCode       := EG_OLEEXCEPTION
       oErr:Operation     := ProcName()
       oErr:Severity      := ES_ERROR
       oErr:SubCode       := -1
       oErr:SubSystem     := "TOleAuto"

       RETURN Throw( oErr )
   ENDIF

   RETURN Self
oleauto.prg86
TOLEAUTO:METHODGetActiveObject( cClass ) CLASS TOleAuto
METHOD GetActiveObject( cClass ) CLASS TOleAuto

   IF ISCHARACTER( cClass )
      ::hObj := GetOleObject( cClass )
      // ::cClassName := cClass
   ELSE
      Alert( "OLE interface: Invalid parameter type to constructor TOleAuto():GetActiveObject()" )
      ::hObj := NIL
   ENDIF

   RETURN Self
oleauto.prg113
TOLEAUTO:METHODEnd() CLASS TOleAuto
METHOD End() CLASS TOleAuto

   ::hObj := NIL

   RETURN NIL
oleauto.prg127
TOLEAUTO:METHODInvoke( cMethod, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 ) CLASS TOleAuto
METHOD Invoke( cMethod, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 ) CLASS TOleAuto

   LOCAL uObj

   IF uParam6 != NIL
      uObj := OLEInvoke( ::hObj, cMethod, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 )
   ELSEIF uParam5 != NIL
      uObj := OLEInvoke( ::hObj, cMethod, uParam1, uParam2, uParam3, uParam4, uParam5 )
   ELSEIF uParam4 != NIL
      uObj := OLEInvoke( ::hObj, cMethod, uParam1, uParam2, uParam3, uParam4 )
   ELSEIF uParam3 != NIL
      uObj := OLEInvoke( ::hObj, cMethod, uParam1, uParam2, uParam3 )
   ELSEIF uParam2 != NIL
      uObj := OLEInvoke( ::hObj, cMethod, uParam1, uParam2 )
   ELSEIF uParam1 != NIL
      uObj := OLEInvoke( ::hObj, cMethod, uParam1 )
   ELSE
      uObj := OLEInvoke( ::hObj, cMethod )
   ENDIF

   IF OleIsObject()
      RETURN TOleAuto():New( uObj )
   ELSEIF Ole2TxtError() == "DISP_E_EXCEPTION"
      Alert( "OLE exception: " + OleExceptionSource() + ": " + OleExceptionDescription() )
      RETURN Self
   ELSEIF OleError() != 0
      Alert( "OLE error1: " + cMethod + ":   " + Ole2TxtError() )
   ENDIF

   RETURN uObj
oleauto.prg135
TOLEAUTO:METHODSet( cProperty, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 ) CLASS TOleAuto
METHOD Set( cProperty, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 ) CLASS TOleAuto

   IF uParam6 != NIL
      OLESetProperty( ::hObj, cProperty, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 )
   ELSEIF uParam5 != NIL
      OLESetProperty( ::hObj, cProperty, uParam1, uParam2, uParam3, uParam4, uParam5 )
   ELSEIF uParam4 != NIL
      OLESetProperty( ::hObj, cProperty, uParam1, uParam2, uParam3, uParam4 )
   ELSEIF uParam3 != NIL
      OLESetProperty( ::hObj, cProperty, uParam1, uParam2, uParam3 )
   ELSEIF uParam2 != NIL
      OLESetProperty( ::hObj, cProperty, uParam1, uParam2 )
   ELSEIF uParam1 != NIL
      OLESetProperty( ::hObj, cProperty, uParam1 )
   ENDIF

   IF Ole2TxtError() == "DISP_E_EXCEPTION"
      OLEShowException()
   ELSEIF OleError() != 0
      Alert( "OLE error2: " + cProperty + ":   " + Ole2TxtError() )
   ENDIF

   RETURN nil
oleauto.prg168
TOLEAUTO:METHODGet( cProperty, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 ) CLASS TOleAuto
METHOD Get( cProperty, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 ) CLASS TOleAuto

   LOCAL uObj

   IF uParam6 != NIL
      uObj := OLEGetProperty( ::hObj, cProperty, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 )
   ELSEIF uParam5 != NIL
      uObj := OLEGetProperty( ::hObj, cProperty, uParam1, uParam2, uParam3, uParam4, uParam5 )
   ELSEIF uParam4 != NIL
      uObj := OLEGetProperty( ::hObj, cProperty, uParam1, uParam2, uParam3, uParam4 )
   ELSEIF uParam3 != NIL
      uObj := OLEGetProperty( ::hObj, cProperty, uParam1, uParam2, uParam3 )
   ELSEIF uParam2 != NIL
      uObj := OLEGetProperty( ::hObj, cProperty, uParam1, uParam2 )
   ELSEIF uParam1 != NIL
      uObj := OLEGetProperty( ::hObj, cProperty, uParam1 )
   ELSE
      uObj := OLEGetProperty( ::hObj, cProperty )
   ENDIF

   IF Ole2TxtError() $ "DISP_E_MEMBERNOTFOUND | "+;
                       "DISP_E_BADPARAMCOUNT | " +;
                       "DISP_E_EXCEPTION"
      uObj := ::Invoke( cProperty, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 )
   ELSE
      IF OleIsObject()
         RETURN TOleAuto():New( uObj )
      ELSEIF OleError() != 0
         Alert( "OLE error3: " + cProperty + ":   " + Ole2TxtError() )
      ENDIF
   ENDIF

   RETURN uObj
oleauto.prg194
TOLEAUTO:METHODOnError( uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 ) CLASS TOleAuto
METHOD OnError( uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 ) CLASS TOleAuto

   LOCAL cMsg := __GetMessage()

   IF !( Left( cMsg, 1 ) == "_" )
      RETURN ::Get( cMsg, uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 )
   ENDIF

   RETURN ::Set( SubStr( cMsg, 2 ), uParam1, uParam2, uParam3, uParam4, uParam5, uParam6 )
oleauto.prg230
EXIT PROCEDUREOLEEXIT()
EXIT PROCEDURE OLEEXIT()

   OLEUninitialize()

   RETURN
oleauto.prg240
FUNCTIONCreateObject( cString )
FUNCTION CreateObject( cString )
   RETURN TOleAuto():New( cString )
oleauto.prg246
FUNCTIONGetActiveObject( cString )
FUNCTION GetActiveObject( cString )
   RETURN TOleAuto():GetActiveObject( cString )
oleauto.prg249
PROCEDUREOleShowException()
PROCEDURE OleShowException()

   Alert( OleExceptionSource() + ": " + OleExceptionDescription() )

   RETURN
oleauto.prg252

Page url: http://www.yourdomain.com/help/index.html?hbole.htm