Página 1 de 1

ActiveX - Para ver se o Adobe Reader foi instalado

Enviado: 22 Out 2011 00:02
por Pablo César
Existe alguma função equivalente em Harbour como a IsActivex() que tem em FiveWin ?
Antes de chamar Load após o objeto da TActiveX() gostaria de verificar se o Adobe foi instalado. Algo assim:

Código: Selecionar todos

    Function testa PDFActivex(oWnd)
       MyProgID := ""
       if IsActivex( "PDF.PdfCtrl.1" ); MyProgID := "PDF.PdfCtrl.1"; endif
       if IsActivex( "PDF.PdfCtrl.2" ); MyProgID := "PDF.PdfCtrl.2"; endif
       if IsActivex( "PDF.PdfCtrl.3" ); MyProgID := "PDF.PdfCtrl.3"; endif
       if IsActivex( "PDF.PdfCtrl.4" ); MyProgID := "PDF.PdfCtrl.4"; endif
       if IsActivex( "PDF.PdfCtrl.5" ); MyProgID := "PDF.PdfCtrl.5"; endif
       if IsActivex( "PDF.PdfCtrl.6" ); MyProgID := "PDF.PdfCtrl.6"; endif
       if IsActivex( "PDF.PdfCtrl.7" ); MyProgID := "PDF.PdfCtrl.7"; endif
       if Empty( MyProgID )
          MsgStop( 'No PDF Activex installed' )
          return .f.
       endif
       ActiveX = TActiveX():New( oWnd, MyProgID )
       return .t.
Pois sem essa verificação, está sujeito a erro "No exported method".

ActiveX

Enviado: 22 Out 2011 16:06
por sygecom
Olá Pablo,

Pode criar sua própria função, exemplo em xHarbour:

Código: Selecionar todos

FUNCTION IsActivex(cACTIVEX)
TRY
   oWord := GetActiveObject( cACTIVEX )
CATCH e
   TRY
      oWord := CreateObject( cACTIVEX )
   CATCH e
      RETURN(.F.)
   END
END
RETURN(.T.)

ActiveX

Enviado: 22 Out 2011 21:09
por Pablo César
Grande Leonardo ! Até não tinha consciência que o GetActiveObject() também existia no Harbour... daí foi fácil implementar o TRY / CATCH que para o Harbour seria BEGIN SEQUENCE / RECOVER criando comando no inicio do programa, ficando desta maneira:

Código: Selecionar todos

#xcommand TRY              => BEGIN SEQUENCE WITH { |e| break( e ) }
#xcommand CATCH [<!oErr!>] => RECOVER [USING <oErr>] <-oErr->

..//..
   MyProgID := ""
   For i=1 to 9
       if IsActivex( "PDF.PdfCtrl."+Str(i,1,0) ); MyProgID := "PDF.PdfCtrl."+Str(i,1,0); endif
   Next
   if IsActivex( "AcroPDF.PDF.1" ); MyProgID := "AcroPDF.PDF.1"; endif
   If Empty( MyProgID )
      MsgStop( 'Deve instalar o Adobe Reader !' )
      Return .f.
   Endif
..//..
Obrigado colega !