FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour SET MULTIPLE EN HARBOUR
Posts: 152
Joined: Mon Feb 13, 2006 08:23 PM

SET MULTIPLE EN HARBOUR

Posted: Tue Apr 05, 2022 07:30 AM

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
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM

Re: SET MULTIPLE EN HARBOUR

Posted: Tue Apr 05, 2022 07:43 AM

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

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: SET MULTIPLE EN HARBOUR

Posted: Tue Apr 05, 2022 09:13 AM
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
Posts: 152
Joined: Mon Feb 13, 2006 08:23 PM

Re: SET MULTIPLE EN HARBOUR

Posted: Tue Apr 05, 2022 09:39 AM

Gracias, Antonio

FWH 20.12 BCC7
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: SET MULTIPLE EN HARBOUR

Posted: Tue Apr 05, 2022 10:21 AM
Gracias a Cristobal que nos ha compartido esta funci贸n que nos sirve para controlar el SET MULTIPLE OFF

Code (fw): Select all Collapse
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
Posts: 152
Joined: Mon Feb 13, 2006 08:23 PM

Re: SET MULTIPLE EN HARBOUR

Posted: Tue Apr 05, 2022 06:25 PM

Gracias, Antonio y Crist贸bal

Saludos

FWH 20.12 BCC7
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM

Re: SET MULTIPLE EN HARBOUR

Posted: Tue Apr 05, 2022 09:31 PM
incluir libreria hbwin.lib

Code (fw): Select all Collapse
/*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)
Posts: 257
Joined: Mon Jun 10, 2013 06:40 PM

Re: SET MULTIPLE EN HARBOUR

Posted: Thu Apr 07, 2022 04:26 PM
Alguien me paso esto y funciono : (para no tener mas de 1 corriendo)
xHarbour

Code (fw): Select all Collapse
__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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: SET MULTIPLE EN HARBOUR

Posted: Fri Apr 08, 2022 11:18 AM

Javier,

Muy buena soluci贸n! :-)

gracias por compartirla!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: SET MULTIPLE EN HARBOUR

Posted: Sat Apr 09, 2022 02:24 PM

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

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion