Jump to content
Fivewin Brasil

executar sistema em aberto


Luiz Fernando

Recommended Posts

Assim, impede que se abra no mesmo micro, se quer abrir, comente.

   IF ISEXERUNNING( CFILENAME( HB_ARGV( 0 ) ) )
	      MsgInfo( "Sistema.exe Já Está Rodando Nesta Máquina","Sistema.exe")
	      SHOWWINDOW( FINDWINDOW( 0, "Sistema.exe" ), 9 )
	      SETFOREGROUNDWINDOW( FINDWINDOW( 0, "Sistema" ) )
	      FECHA_TUDO()
	      RETURN NIL
	   ENDIF


Link to comment
Share on other sites

Ola Kapiaba, fiz igual seu exemplo, mais ele não chama o sistema

function chamar_analise()
  if IsExeRunning("analise.exe")
     SHOWWINDOW( FINDWINDOW( 0, "analise.exe" ), 9 )
      SETFOREGROUNDWINDOW( FINDWINDOW( 0, "analise" ) )
      ? 'não acontece nada'
  else
     WinExec( cPath1+'fluxo\analise.exe' )
  endIf
return .t.

 

Link to comment
Share on other sites

// \SAMPLES\TUTOR04.PRG MODIFICADO PARA CHAMAR UM .BAT.

// We are going to build a PullDown menu and we are going to assign it
// to our main Window
	// This example is the typical way of start building a FiveWin program
	#include "FiveWin.ch"
	static oWnd
	//----------------------------------------------------------------------------//
	function Main()
	   local oIco, oBar, oBmp
	   DEFINE ICON oIco FILE "..\icons\fax.ico"
	   DEFINE WINDOW oWnd FROM 1, 1 TO 22, 75 ;
      TITLE "FiveWin sample" ;
      MENU  BuildMenu() ;
      COLOR "B/W" ;
      ICON oIco
	   DEFINE BUTTONBAR oBar _3D SIZE 26, 27 OF oWnd
	   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\new.bmp" FLAT ;
      ACTION ( CHAMA_TUTOR_VIA_BAT() )
	      /*
      ACTION MsgInfo( "New" ) ;
      TOOLTIP "Creates a new document"
      */
	   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\open.bmp" FLAT ;
      ACTION MsgInfo( cGetFile( "*.*", "Select a document to open" ) ) ;
      TOOLTIP "Opens a document" WHEN .f.
	   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\floppy.bmp" FLAT ;
      ACTION MsgInfo( Time() ) TOOLTIP "Saves this document"
	   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\printer.bmp" FLAT ;
      ACTION MsgInfo( "Prints this document" ) TOOLTIP "Print this document" GROUP
	   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\prop.bmp" FLAT ;
      ACTION PrinterSetup() TOOLTIP "Setup the printer"
	   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\HelpInd.bmp" FLAT ;
      ACTION MsgInfo( Version() ) TOOLTIP "A multiple lines" + ;
      Chr( 13 ) + Chr( 10 ) + "tooltip!" GROUP
	   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\Help.bmp" FLAT ;
      ACTION MsgInfo( "fivewin power!" ) TOOLTIP "fivewin power!"
	   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\Exit.bmp" FLAT ;
      ACTION oWnd:End() TOOLTIP "Exit this app" GROUP
	   DEFINE MESSAGE OF oWnd ;
      PROMPT FWVERSION + " " + FWCOPYRIGHT ;
      NOINSET CENTERED KEYBOARD DATE CLOCK
	   DEFINE BITMAP oBmp FILENAME "..\bitmaps\fiveback.bmp"
	   oWnd:bPainted = { | hDC | BmpTiled( hDC, oWnd, oBmp ) }
	   ACTIVATE WINDOW oWnd ;
      VALID MsgYesNo( "Do you want to quit ?" )
	return nil
	//----------------------------------------------------------------------------//
	function BuildMenu()
	   local oMenu
	   MENU oMenu
      MENUITEM "Information"
      MENU
         MENUITEM "&About..." ;
            ACTION MsgInfo( FWDESCRIPTION ) ;
            FILENAME "..\bitmaps\16x16\info.bmp"
         SEPARATOR
         MENUITEM "&End..."  ;
            ACTION oWnd:End() FILENAME "..\bitmaps\16x16\exit.bmp"
	      ENDMENU
	      MENUITEM "&Clients"
      MENU
         MENUITEM "&New..." ;
            ACTION ( MsgStop( "New Clients" ),;
                     oWnd:Say( 5, 5, "New Clients...", "GR+/G" ) ) ;
            FILENAME "..\bitmaps\16x16\faces.bmp"
	         MENUITEM "&Modify..."  ACTION MsgInfo( "Modif. Clients" ) ;
            FILENAME "..\bitmaps\edit.bmp"
	         MENUITEM "&Delete..."  ACTION MsgAlert( "Del Clients" ) ;
            FILENAME "..\bitmaps\16x16\delete.bmp"
	         SEPARATOR
	         MENUITEM "&Browse..."  ACTION MsgInfo( "Browse Clients" ) ;
            FILENAME "..\bitmaps\16x16\browse.bmp"
	      ENDMENU
	      MENUITEM "&Utilities"
      MENU
         MENUITEM "&Calculator..." ACTION WinExec( "Calc" ) ;
            FILENAME "..\bitmaps\16x16\calc.bmp"
	         MENUITEM "&Internet..." ;
            ACTION WinExec( "start iexplore www.fivetech.com", 0 ) ;
            FILENAME "..\bitmaps\16x16\explorer.bmp"
      ENDMENU
   ENDMENU
	return oMenu
	//----------------------------------------------------------------------------//
	STATIC FUNCTION BmpTiled( hDC, oWnd, oBmp )
	   local nWidth := oWnd:nWidth(), nHeight := oWnd:nHeight()
   local nRow := 0, nCol := 0, n
   local nBmpWidth  := oBmp:nWidth(),  nBmpHeight := oBmp:nHeight()
	   if oBmp:hBitmap == 0
      return nil
   endif
	   while nRow < nHeight
      nCol = 0
      while nCol < nWidth
         PalBmpDraw( hDC, nRow, nCol, oBmp:hBitmap )
         nCol += nBmpWidth
      end
      nRow += nBmpHeight
   end
	return nil
	//----------------------------------------------------------------------------//
	FUNCTION CHAMA_TUTOR_VIA_BAT()  // ASSIM MARCELO.
	   LOCAL NOME_ARQ, NREGISTRO
	   // AEVAL(DIRECTORY( "TUTOR04.BAT"     ),{ |aFILE| FERASE(aFILE[F_NAME]) } )
	   IF .NOT. FILE( "TUTOR04.BAT" )
	      NOME_ARQ := FCREATE("TUTOR04.BAT")
	      NREGISTRO := "@ECHO OFF"                                          ;
                   + CRLF        +                                      ;
                   "CLS"         +                                      ;
                   + CRLF + CRLF +                                      ;
                   ".\TUTOR04 > NUL"  +                                 ;
                   + CRLF + CRLF +                                      ;
                   "CLS"         +                                      ;
                   + CRLF        +                                      ;
                   "EXIT"
	      FWRITE( NOME_ARQ, NREGISTRO )
	      FCLOSE( NOME_ARQ )
	   ENDIF
	   WinExec( "TUTOR04.BAT", 0 )
	RETURN NIL


Link to comment
Share on other sites

Ele não lê. hahahahaah, essa faz tempo e já não utilizo, mas não deve ter tido mudanças. enfim.

 

IF(!PCS_StatusExe("nome_do_exe.exe"))
    
    // faz o que quer

    
ENDIF
**------------------------------------------------------------------------------**
** Finalidade : Verificar se um Programa está em execução
**------------------------------------------------------------------------------**
    FUNCTION  PCS_StatusExe(cExecutavel)
**------------------------------------------------------------------------------**
LOCAL oWmiService,oListaProcess,oProcessos,Wexecutando:=.F.
oWmiService=Service_WMI()
oListaProcess:=oWmiService:ExecQuery("SELECT * FROM Win32_Process WHERE Name='"+cExecutavel+"'")

FOR EACH oProcessos IN oListaProcess
    Wexecutando:=.t.
Next
RETURN(Wexecutando)

**----------------------------------------------------------**
    STATIC FUNCTION  Service_WMI()
**----------------------------------------------------------**
    STATIC oWmiService
    LOCAL oScriptObj
    IF(oWmiService==NIL)
        oScriptObj=CREATEOBJECT("wbemScripting.SwbemLocator")
        oWmiService=oScriptObj:ConnectServer()
    ENDIF
    RETURN(oWmiService)
Link to comment
Share on other sites

Obigado Kapiaba e Aferra, mais nenhuma das duas solução deu certo, outro detalhe que ocorre aqui que se eu chamar o sistema uma vez com o comando

WinExec( cPath1+'fluxo\analise.EXE' )

e depois fechar ele, não consigo mais abrir o mesmo, preciso finalizar meu sistema principal.

  if IsExeRunning("analise.EXE")

     ? 'entra aqui como se o programa tivesse aberto, alem de estar fechado no rodape, verifiquei no processo do windows e tb não esta la'

else

     WinExec( cPath1+'fluxo\analise.EXE' )

endif

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...