SET MULTIPLE EN HARBOUR

Post Reply
Ramón J.
Posts: 152
Joined: Mon Feb 13, 2006 8:23 pm

SET MULTIPLE EN HARBOUR

Post by Ramón J. »

Hola a todos

He observado que la aplicación, cuando le pongo el SET MULTIPLE OFF no funciona y abre tantas ventanas de la aplicación como clicks le des al acceso directo. ¿Hay alguna equivalencia en Harbour?

Saludos
FWH 20.12 BCC7
hmpaquito
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: SET MULTIPLE EN HARBOUR

Post by hmpaquito »

Hola,

No sé si hay equivalencia para el SET MULTIPLE OFF

Una alternativa es crear un fichero cualquiera ( FCreate("Semaforo.Nul", FO_EXCLUSIVE) ) en exclusivo. El primer usuario / primera vez que entra pilla semaforo verde. Las siguientes pulsaciones no permitirá acceder. Si el programa saliera por error automaticamente desaparece el enlace con Semaforo.Nul

Salu2
User avatar
Antonio Linares
Site Admin
Posts: 42595
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 38 times
Been thanked: 86 times
Contact:

Re: SET MULTIPLE EN HARBOUR

Post by Antonio Linares »

Ramón,

Efectivamente parece que no funciona SET MULTIPLE OFF en FWH 32/64 bits

Vamos a revisar si este código nos permite implementarlo:
https://stackoverflow.com/questions/20874381/get-a-process-id-in-c-by-name
regards, saludos

Antonio Linares
www.fivetechsoft.com
Ramón J.
Posts: 152
Joined: Mon Feb 13, 2006 8:23 pm

Re: SET MULTIPLE EN HARBOUR

Post by Ramón J. »

Gracias, Antonio
FWH 20.12 BCC7
User avatar
Antonio Linares
Site Admin
Posts: 42595
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 38 times
Been thanked: 86 times
Contact:

Re: SET MULTIPLE EN HARBOUR

Post by Antonio Linares »

Gracias a Cristobal que nos ha compartido esta función que nos sirve para controlar el SET MULTIPLE OFF

Code: Select all | Expand

Function IsExeRunning( tcName, lTerminate )

   Local oLocator
   Local oWMI
   Local oProcesses
   Local oProcess
   Local lIsRunning
   Local nRet         := 0
   Local aProcess     := {}
   DEFAULT lTerminate := .F.

   oLocator   := CREATEOBJECT( "WBEMScripting.SWBEMLocator" )
   oWMI       := oLocator:ConnectServer()
   oWMI:Security_:ImpersonationLevel := 3

   oProcesses := oWMI:ExecQuery([SELECT * FROM Win32_Process]) // WHERE Name = '] + tcName + ['])
   lIsRunning := .F.
   if oProcesses:Count > 0
       For Each oProcess in oProcesses
          if Upper( AllTrim( oProcess:Name ) ) == Upper( AllTrim( tcName ) )
             hRet := oProcess:Handle
             lIsRunning := .T.
             if lTerminate
                nRet    := oProcess:Terminate( 0 )
                if nRet = 0
                   hRet       := -1   // ¿?
                   lIsRunning := .F.
                endif
             endif
          endif
          //AAdd( aProcess, { oProcess:Name, oProcess:Handle } )
       Next
   endif
   //XBrowse( aProcess )
   
Return lIsRunning
regards, saludos

Antonio Linares
www.fivetechsoft.com
Ramón J.
Posts: 152
Joined: Mon Feb 13, 2006 8:23 pm

Re: SET MULTIPLE EN HARBOUR

Post by Ramón J. »

Gracias, Antonio y Cristóbal

Saludos
FWH 20.12 BCC7
User avatar
carlos vargas
Posts: 1723
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: SET MULTIPLE EN HARBOUR

Post by carlos vargas »

incluir libreria hbwin.lib

Code: Select all | Expand


/*Mutex constant for application*/
#define MUTEX_NAME         "KDSOFT_MYAPP"

STATIC hMutex

PROCEDURE Main()
   //main code :-)
RETURN

INIT PROCEDURE Main_Init()

   hMutex := wapi_CreateMutex( NIL, NIL, MUTEX_NAME )

   IF !Empty( hMutex ) .AND. wapi_GetLastError() == 0
      //allow execution of application
   ELSE
      MsgAlert( "La aplicación ya esta en ejecución, seleccionela en la barra de tareas.", "Alerta" )
      MyQuit()
   ENDIF

RETURN

/*-------------------------------------------------------------------------------------------------*/

EXIT PROCEDURE Main_End()

   IF !Empty( hMutex )
      hMutex := NIL
   ENDIF

   MyQuit()

RETURN


FUNCTION MyQuit()

   PostQuitMessage( 0 )
   __Quit()

RETURN


 
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
VitalJavier
Posts: 244
Joined: Mon Jun 10, 2013 6:40 pm
Has thanked: 1 time

Re: SET MULTIPLE EN HARBOUR

Post by VitalJavier »

Alguien me paso esto y funciono : (para no tener mas de 1 corriendo)
xHarbour

Code: Select all | Expand


__cExe := cFileName( HB_ARGV( 0 ) )
IF IsExeRunning( __cExe )  // Verifica que no Exista una Aplicacion ya Corriendo en la Computadora
    MiMsgStop( {"1 No Puedes tener 2 Aplicaciones Abiertas..."}, "Alto!", , .T., 5, .F.)
   Cerrar1()
ENDIF          
 
User avatar
Antonio Linares
Site Admin
Posts: 42595
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 38 times
Been thanked: 86 times
Contact:

Re: SET MULTIPLE EN HARBOUR

Post by Antonio Linares »

Javier,

Muy buena solución! :-)

gracias por compartirla!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: SET MULTIPLE EN HARBOUR

Post by nageswaragunupudi »

SET MULTIPLE ON/OFF
is implemented in FWH2203 to be released in a few days.
Regards

G. N. Rao.
Hyderabad, India
Post Reply