Jump to content
Fivewin Brasil

Bloqueio do sistema


Recommended Posts

Boa tarde Pessoal,

Será que existe alguma forma  de fechar o sistema automaticamente por falta de uso

Tenho uma situação que o usuario entra no sistema e por algum motivo, deixa o sistema aberto no seu usuario.

Dessa forma outro usuario acaba usando sua senha 

Preciso achar uma solução para caso o sistema nao for usado por algum tempo ele feche

Obrigado

 

 

Link to comment
Share on other sites

seria mais ou menos isso aqui: (peguei aqui no forum mesmo, mas não lembro de quem... acabei que não usei)

Function Fnct_StartCounterTime ()

   Define Timer oTimerExit of oWndMain Interval nInterval Action ( iif( sysIdleSecs()>nSecondsToOut, fExit(),))
   oTimerExit:Activate()

Return NIL

function fExit()

    oTimerExit:Deactivate()
    //oTimerExit:End()

    MsgInfo( "Lembre de Fechar Sistema caso não vá mais usar","Sistema Inativo")
    
    oTimerExit:Activate()
    
    *
	 MsgAlert('Sistema Será Fechado por Inatividade','SyS RlI')

    oWndMain:End()

	SET RESOURCES TO
	
	oImgFundo:End()
	oImgLogo:End()
	oFntMsg:End()
	
	FecharPrograma()
	*

return .t.

#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
#include <stdio.h>

WINUSERAPI BOOL WINAPI GetLastInputInfo(PLASTINPUTINFO);
typedef  BOOL (WINAPI *GETLASTINPUTINFO_)(PLASTINPUTINFO);

HB_FUNC( SYSIDLESECS )
{
   HINSTANCE handle= LoadLibrary("user32.dll");
   if ( handle)
   {
      GETLASTINPUTINFO_ pFunc;
      pFunc = GetProcAddress( handle,"GetLastInputInfo" );
      if (pFunc)
      {
         LASTINPUTINFO lpi;

         lpi.cbSize = sizeof(LASTINPUTINFO);

         if (!pFunc(&lpi))
         {
            hb_retni(0);
         }
         else
         {
            hb_retnd( ( DOUBLE ) ( GetTickCount() - lpi.dwTime ) * 0.001 );
         }
      }
   else
      {
         hb_retni(0);
      }
   }

   if (handle)
      {
         FreeLibrary( handle);
      }
}
#pragma ENDDUMP
***********************************************************************************************+

 

Link to comment
Share on other sites

2 minutos atrás, Theotokos disse:

seria mais ou menos isso aqui: (peguei aqui no forum mesmo, mas não lembro de quem... acabei que não usei)

Function Fnct_StartCounterTime ()

   Define Timer oTimerExit of oWndMain Interval nInterval Action ( iif( sysIdleSecs()>nSecondsToOut, fExit(),))
   oTimerExit:Activate()

Return NIL

function fExit()

    oTimerExit:Deactivate()
    //oTimerExit:End()

    MsgInfo( "Lembre de Fechar Sistema caso não vá mais usar","Sistema Inativo")
    
    oTimerExit:Activate()
    
    *
	 MsgAlert('Sistema Será Fechado por Inatividade','SyS RlI')

    oWndMain:End()

	SET RESOURCES TO
	
	oImgFundo:End()
	oImgLogo:End()
	oFntMsg:End()
	
	FecharPrograma()
	*

return .t.

#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
#include <stdio.h>

WINUSERAPI BOOL WINAPI GetLastInputInfo(PLASTINPUTINFO);
typedef  BOOL (WINAPI *GETLASTINPUTINFO_)(PLASTINPUTINFO);

HB_FUNC( SYSIDLESECS )
{
   HINSTANCE handle= LoadLibrary("user32.dll");
   if ( handle)
   {
      GETLASTINPUTINFO_ pFunc;
      pFunc = GetProcAddress( handle,"GetLastInputInfo" );
      if (pFunc)
      {
         LASTINPUTINFO lpi;

         lpi.cbSize = sizeof(LASTINPUTINFO);

         if (!pFunc(&lpi))
         {
            hb_retni(0);
         }
         else
         {
            hb_retnd( ( DOUBLE ) ( GetTickCount() - lpi.dwTime ) * 0.001 );
         }
      }
   else
      {
         hb_retni(0);
      }
   }

   if (handle)
      {
         FreeLibrary( handle);
      }
}
#pragma ENDDUMP
***********************************************************************************************+

 

Static oTimerExit
Static nInterval
*
Function Main()
   *
   Public nSecondsToOut:= 55 //(segundos)

   nInterval := 1*60000  //(1 x 60000 = 1 minuto)

 

Acrescentar isso no fotnte principal e chamar a função no ON INIT
 

Link to comment
Share on other sites

22 minutos atrás, edutraini disse:

Bom dia Theotokos 

Deu certo 

na verdade em vez de fechar o programa ele fecha a conexao do usuario que esta aberto e abre a tela para logar de novo

ou seja usei a sua ideia

Obrigado

Bom dia. Nada impede que você cerre(feche) o programa em definitivo, somente o da estação de trabalho.  abs.

Regards, saludos.

Link to comment
Share on other sites

42 minutos atrás, kapiaba disse:

Bom dia. Nada impede que você cerre(feche) o programa em definitivo, somente o da estação de trabalho.  abs.

Regards, saludos.

optei por fazer assim, porque no meu caso tinha usuário que abria uma venda, lança alguns produtos e sai para mostrar algo para o cliente, deixando tudo aberto... ai com tempo iria fechar o sistema e perder tudo que lançou, assim pede a senha novamente, o vendedor coloca a senha dele e segue a venda aberta...

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...