SETNEWTIME() no funciona en Windows 7?

Post Reply
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

SETNEWTIME() no funciona en Windows 7?

Post by karinha »

Maestros, hay algun otro comando que cambie la hora y fecha del PC en Windows 7?

Este comando solo funciona en Windows XP.

Code: Select all

   SETNEWTIME( wHOR, wMIN, wSEG )
 
   SETNEWDATE( wANO, wMES, wDIA )
 
Gracias, regards, Saludos.
João Santos - São Paulo - Brasil
Valdir
Posts: 20
Joined: Fri Feb 10, 2006 5:21 pm

Re: SETNEWTIME() no funciona en Windows 7?

Post by Valdir »

Antonio ...

Is there any solution to this problem?

Thanks
Valdir - Jundiaí - S.P. - Brasil
Fivewin 16.08
User avatar
quique
Posts: 408
Joined: Sun Aug 13, 2006 5:38 am
Contact:

Re: SETNEWTIME() no funciona en Windows 7?

Post by quique »

no es de fivewin y no lo he probado desde él, pero podias intentar:

winexec( "date 25/02/2013" ) // el formato puede cambiar dependiendo de tu configuración

y

winexec( "time 08:13:45.08" )
Saludos
Quique
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: SETNEWTIME() no funciona en Windows 7?

Post by karinha »

Quique, creo q no va funcionar, porque WINDOWS 7 solo se puede modificar la fecha y hora, como administrador.

Gracias, salu2.
João Santos - São Paulo - Brasil
User avatar
quique
Posts: 408
Joined: Sun Aug 13, 2006 5:38 am
Contact:

Re: SETNEWTIME() no funciona en Windows 7?

Post by quique »

Hice una pregunta creo relacionada con el problema que tienes para pedir autorización como administrador (http://forums.fivetechsupport.com/viewt ... =6&t=26090), a lo que Antonio me dio una posible solución, que no pude probar porque no supe como meter el código C en mi programa, así que no se si te sirva de algo, pero aquí está el código:

Code: Select all

BOOL IsUserAdmin(VOID)
/*++ 
Routine Description: This routine returns TRUE if the caller's
process is a member of the Administrators local group. Caller is NOT
expected to be impersonating anyone and is expected to be able to
open its own process and process token. 
Arguments: None. 
Return Value: 
   TRUE - Caller has Administrators local group. 
   FALSE - Caller does not have Administrators local group. --
*/ 
{
BOOL b;
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup; 
b = AllocateAndInitializeSid(
    &NtAuthority,
    2,
    SECURITY_BUILTIN_DOMAIN_RID,
    DOMAIN_ALIAS_RID_ADMINS,
    0, 0, 0, 0, 0, 0,
    &AdministratorsGroup); 
if(b) 
{
    if (!CheckTokenMembership( NULL, AdministratorsGroup, &b)) 
    {
         b = FALSE;
    } 
    FreeSid(AdministratorsGroup); 
}

return(b);
}
 
Saludos
Quique
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: SETNEWTIME() no funciona en Windows 7?

Post by Antonio Linares »

Joao,

Creo qye te refieres a la función SetFTime() de FWH. Dicha función usa esta del API de Windows:

http://msdn.microsoft.com/en-us/library ... s.85).aspx

En la documentación no comenta nada acerca de Windows 7. Habrá que seguir buscando en google :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: SETNEWTIME() no funciona en Windows 7?

Post by karinha »

Maestro, el que haria este ejemplo en WINDOWS XP? En WINDOWS 7 no hice nada.

El que intento, és CAMBIAR la hora y fecha del WINDOWS 7 desde una página de internet.

Code: Select all

// testing the FiveWin SetFTime() function to change the
// time & date of a file
// And the new GetFTime() to retrieve the time and date

#include "FiveWin.Ch"
#include "fileio.ch"

function Main()

   local hFile := FOpen( "customer.dbf", FO_READWRITE )
   local aInfo

   SET DATE FRENCH
   SET CENTURY ON

   SetFTime( hFile, "01:02:03", CToD( "11/12/96" ) )

   MsgInfo( "Done!" )

   aInfo = GetFTime( hFile )

   MsgInfo( "Time: " + aInfo[ 1 ] )
   
   if __SetCentury()
      aInfo[ 2 ] = CToD( Str( Day( aInfo[ 2 ] ), 2 ) + "/" + Str( Month( aInfo[ 2 ] ), 2 ) + ;
                         "/" + Str( Year( aInfo[ 2 ] ) - 2000, 4 ) )
   endif

   MsgInfo( "Date: " + DToC( aInfo[ 2 ] ) )

   FClose( hFile )

return nil
 
Gracias, salu2
João Santos - São Paulo - Brasil
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: SETNEWTIME() no funciona en Windows 7?

Post by Antonio Linares »

A que te refieres desde una página de internet ?

Donde está tu EXE ? :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: SETNEWTIME() no funciona en Windows 7?

Post by karinha »

Maestro, mira este ejemplo por favor. Tengo la hora y fecha desde una pagina de internet, después me gustaria de podrer actualizar la hora y fecha de windows en tiempo real, si el hora y fecha estean erroneas.

Code: Select all

// Funcao Para Mostrar a Hora de Brasilia em Tempo Real na Tela.

#Include "FiveWin.ch"

STATIC oDlg, oTimer, oWnd

FUNCTION BRASILIA()

   LOCAL oIco, aGet := ARRAY(5), cHoraBra := "        "

   DEFINE DIALOG oDlg TITLE "Hora de Brasilia" COLOR "W+/B"

   @ 0.50, 09 SAY "Hora de Brasilia" SIZE 050, 10 OF oDlg                    ;
              COLORS CLR_BLACK, CLR_WHITE CENTER

   @ 2, 08 GET aGet[1] VAR cHoraBra PICTURE "99:99:99" OF oDlg CENTER

   aGet[1]:lBtnTransparent := .t.       // transparent button get aGet[1]
   
   aGet[1]:Disable()                    // When( .F. )
   aGet[1]:lBtnTransparent := .t.       // transparent button get aGet[1]
   aGet[1]:lAdjustBtn      := .t.       // Button Get Adjust Witdh aGet[1]
   aGet[1]:lDisColors      := .f.       // Deactive disable color
   aGet[1]:nClrTextDis     := CLR_WHITE // Color text disable status
   aGet[1]:nClrPaneDis     := CLR_BLACK // Color Pane disable status
   
   aGet[1]:lAdjustBtn      := .t.

   @ 3, 10 BUTTON "&Saida" SIZE 40, 12 DEFAULT                               ;
           ACTION( oTimer:DeActivate(), oDlg:End() ) CANCEL UPDATE

   ACTIVATE DIALOG oDlg CENTERED  ;
            ON INIT( PEGA_TIMER_BRASIL( aGet, oWnd ) )

RETURN NIL

//-> ACIONA O TIMER DO RELOGIO DE BRASILIA NO DIALOGO

FUNCTION PEGA_TIMER_BRASIL( aGet, oWnd )

   DEFINE TIMER oTimer INTERVAL 0   OF oDlg                            ;
          ACTION HORABRASILIA( aGet, oWnd )

   ACTIVATE TIMER oTimer

RETURN NIL

//-> HORA EXATA DE BRASILIA

FUNCTION HORABRASILIA( aGet, oWnd )

   LOCAL oHttp, cHtml
   LOCAL cHora

   IF IsInternet() // Se tiver internet ativa

      oHttp := CreateObject( "winhttp.winhttprequest.5.1" )
      oHttp:Open( "GET", "http://24timezones.com/pt_horamundial/brasilia_hora_local.php" , .F. )
      oHttp:Send()
      cHtml:= oHttp:ResponseText()
      cHtml:= left(alltrim(StrExtract(cHtml, '<span id="currentTime">', '</span>' )),8)

      cHora := TRANSF( cHtml, "99:99:99" )

      aGet[1]:VARPUT( cHora )
      aGet[1]:Refresh()

   ELSE

      cHora := [SEM NET]

      aGet[1]:VARPUT( cHora )
      aGet[1]:Refresh()

   ENDIF

RETURN NIL

STATIC FUNCTION StrExtract(cText,cAfter,cBefore)

   LOCAL cRet := SUBSTR(cText,AT(cAfter,cText) + LEN(cAfter))
   LOCAL n

   IF (n := AT(cBefore,cRet)) > 0
      cRet := LEFT(cRet,n - 1)
   ENDIF

RETURN(cRet)

//-> Funcao para checar a Internet
FUNCTION IsInternet()

   LOCAL cIp, cVret := .F.

   WsaStartUp()

   // conforme pessoal do forum, e para chamar duas vezes
   cIp := GETHOSTBYNAME( "microsoft.com" )
   cIp := GETHOSTBYNAME( "microsoft.com" )

   WsaCleanUp()

   // Seguranca caso o provedor da microsoft esteja fora do ar...
   IF ( cIp <= "0.0.0.0" )

      WsaStartUp()

      cIp := GetHostByName( "google.com" )
      cIp := GetHostByName( "google.com" )

      WsaCleanUp()

   ENDIF

RETURN( cIp<>"0.0.0.0" )


// FIM DO PROGRAMA
 
Gracias, saludos.
João Santos - São Paulo - Brasil
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: SETNEWTIME() no funciona en Windows 7?

Post by karinha »

UP
João Santos - São Paulo - Brasil
Post Reply