oribeiro Posted February 21, 2019 Report Share Posted February 21, 2019 Pessoal, Quero dar um LogOff no usuário do terminal server assim que ele fechar o sistema. Tem como fazer isso? Quote Link to comment Share on other sites More sharing options...
emotta Posted February 21, 2019 Report Share Posted February 21, 2019 Tinha isso em meu sistema a muitos anos atras a pedido de um cliente. Veja ai, não sei se funciona, faça um teste: #pragma BEGINDUMP #include <windows.h> #include "hbapi.h" // SHUTDOWN() // Funcao que Desliga o Computador no WindowsXP // Chamando somente a função ExitWindowsEx o Windows só vai fazer logoff // é preciso obter privilégios antes HB_FUNC(SHUTDOWN) { HANDLE hToken; TOKEN_PRIVILEGES tkp; if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) hb_retl( FALSE ); LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); if (GetLastError() != ERROR_SUCCESS) hb_retl( FALSE ); if (!ExitWindowsEx( 8, 0 )) hb_retl( FALSE ); } #pragma ENDDUMP Quote Link to comment Share on other sites More sharing options...
oribeiro Posted February 21, 2019 Author Report Share Posted February 21, 2019 Valeu Motta, Mas como eu faço a chamada somente da função ExitWindowsEx para fazer apenas o LogOff? Quote Link to comment Share on other sites More sharing options...
kapiaba Posted February 21, 2019 Report Share Posted February 21, 2019 http://forums.fivetechsupport.com/viewtopic.php?f=3&t=20856&p=110754&hilit=ExitWindowsEx#p110754 Quote Link to comment Share on other sites More sharing options...
oribeiro Posted February 21, 2019 Author Report Share Posted February 21, 2019 Coloquei no meu servidor Windows Server 2008 R2 e funcionou perfeitamente. Daí eu coloquei o executável no servidor do meu cliente que é a mesma versão do Windows e deu o seguinte erro: Erro irrecuperável 9003: Muitas chamadas recursivas ao manipulador de erros. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted February 21, 2019 Report Share Posted February 21, 2019 Erro irrecuperável 9003: 64 Bits? Compare: Memória do seu computer, com a memória do computer do seu cliente, 64 bits, mínimo, 8 Gbs de RAM .OR. MORE. Abs. Quote Link to comment Share on other sites More sharing options...
emotta Posted February 21, 2019 Report Share Posted February 21, 2019 Esse erro foi pq entrou em recursiva a mensagem de erro do FW... Uma pena que não vai dar pra te ajudar mais que isso nesse caso pois já a muitos anos não pego pra ver isso e nem lembro dos detalhes Quote Link to comment Share on other sites More sharing options...
oribeiro Posted February 22, 2019 Author Report Share Posted February 22, 2019 Tranquilo Motta. Obrigado mesmo assim. Vou tentar de outra forma. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted February 22, 2019 Report Share Posted February 22, 2019 #Include "FiveWin.ch" Function ShutDown_Main() IF .NOT. MsgYesNo( "LogOff Windows?", "ShutDown Windows" ) RETURN NIL ENDIF WINEXEC( "SHUTDOWN /L" ) Return Nil // Fim frkiko and aferra 2 Quote Link to comment Share on other sites More sharing options...
oribeiro Posted February 22, 2019 Author Report Share Posted February 22, 2019 Aí João, Resolveu 100%. Muito obrigado. kapiaba 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.