¿Cómo saber la fecha de los cambios a una carpeta?

¿Cómo saber la fecha de los cambios a una carpeta?

Postby JoseAlvarez » Sat Mar 02, 2024 7:02 pm

Amigos,

Necesito saber la ultima fecha en la que una carpeta de windows tuvo cambios.

¿Hay alguna manera?
"Los errores en programación, siempre están entre la silla y el teclado..."

Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin

Carora, Estado Lara, Venezuela.
User avatar
JoseAlvarez
 
Posts: 726
Joined: Sun Nov 09, 2014 5:01 pm

Re: ¿Cómo saber la fecha de los cambios a una carpeta?

Postby Antonio Linares » Sun Mar 03, 2024 8:33 am

Estimado José,

Aquí lo tienes. Lo incluimos para el próximo build de FWH:

function FW_FolderChanged( cFolderPath ) --> { nDay, nMonth, nYear, nHours, nMinutes, nSeconds }

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

    XBrowse( FW_FolderChanged( "c:\fwh" ) )

return nil

#pragma BEGINDUMP

#include <Windows.h>
#include <hbapi.h>

HB_FUNC( FW_FOLDERCHANGED )
{
   const char * folderPath = hb_parc( 1 );
   FILETIME lastWriteTime;
   WIN32_FILE_ATTRIBUTE_DATA fileAttributes;
   SYSTEMTIME systemTime;

   GetFileAttributesEx( folderPath, GetFileExInfoStandard, &fileAttributes );
   lastWriteTime = fileAttributes.ftLastWriteTime;
   FileTimeToSystemTime(&lastWriteTime, &systemTime);

   hb_reta( 6 );
   hb_storvnl( systemTime.wDay, -1, 1 );
   hb_storvnl( systemTime.wMonth, -1, 2 );
   hb_storvnl( systemTime.wYear, -1, 3 );
   hb_storvnl( systemTime.wHour, -1, 4 );
   hb_storvnl( systemTime.wMinute, -1, 5 );
   hb_storvnl( systemTime.wSecond, -1, 6 );
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: ¿Cómo saber la fecha de los cambios a una carpeta?

Postby JoseAlvarez » Sun Mar 03, 2024 9:09 am

Antonio Linares wrote:Estimado José,

Aquí lo tienes. Lo incluimos para el próximo build de FWH:

function FW_FolderChanged( cFolderPath ) --> { nDay, nMonth, nYear, nHours, nMinutes, nSeconds }

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

    XBrowse( FW_FolderChanged( "c:\fwh" ) )

return nil

#pragma BEGINDUMP

#include <Windows.h>
#include <hbapi.h>

HB_FUNC( FW_FOLDERCHANGED )
{
   const char * folderPath = hb_parc( 1 );
   FILETIME lastWriteTime;
   WIN32_FILE_ATTRIBUTE_DATA fileAttributes;
   SYSTEMTIME systemTime;

   GetFileAttributesEx( folderPath, GetFileExInfoStandard, &fileAttributes );
   lastWriteTime = fileAttributes.ftLastWriteTime;
   FileTimeToSystemTime(&lastWriteTime, &systemTime);

   hb_reta( 6 );
   hb_storvnl( systemTime.wDay, -1, 1 );
   hb_storvnl( systemTime.wMonth, -1, 2 );
   hb_storvnl( systemTime.wYear, -1, 3 );
   hb_storvnl( systemTime.wHour, -1, 4 );
   hb_storvnl( systemTime.wMinute, -1, 5 );
   hb_storvnl( systemTime.wSecond, -1, 6 );
}

#pragma ENDDUMP


Muchas Gracias Master, le daré un vistazo y estaré comentando.
"Los errores en programación, siempre están entre la silla y el teclado..."

Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin

Carora, Estado Lara, Venezuela.
User avatar
JoseAlvarez
 
Posts: 726
Joined: Sun Nov 09, 2014 5:01 pm

Re: ¿Cómo saber la fecha de los cambios a una carpeta?

Postby JoseAlvarez » Mon Mar 04, 2024 2:38 pm

Antonio Linares wrote:Estimado José,

Aquí lo tienes. Lo incluimos para el próximo build de FWH:

function FW_FolderChanged( cFolderPath ) --> { nDay, nMonth, nYear, nHours, nMinutes, nSeconds }

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

    XBrowse( FW_FolderChanged( "c:\fwh" ) )

return nil

#pragma BEGINDUMP

#include <Windows.h>
#include <hbapi.h>

HB_FUNC( FW_FOLDERCHANGED )
{
   const char * folderPath = hb_parc( 1 );
   FILETIME lastWriteTime;
   WIN32_FILE_ATTRIBUTE_DATA fileAttributes;
   SYSTEMTIME systemTime;

   GetFileAttributesEx( folderPath, GetFileExInfoStandard, &fileAttributes );
   lastWriteTime = fileAttributes.ftLastWriteTime;
   FileTimeToSystemTime(&lastWriteTime, &systemTime);

   hb_reta( 6 );
   hb_storvnl( systemTime.wDay, -1, 1 );
   hb_storvnl( systemTime.wMonth, -1, 2 );
   hb_storvnl( systemTime.wYear, -1, 3 );
   hb_storvnl( systemTime.wHour, -1, 4 );
   hb_storvnl( systemTime.wMinute, -1, 5 );
   hb_storvnl( systemTime.wSecond, -1, 6 );
}

#pragma ENDDUMP


Master Antonio,

Muchas Gracias. Funciona Muy bien, solo necesito resolver un pequeño detalle.
Me da el dato de la hora con la zona horaria de España. En mi caso, son 7 horas mas adelante que mi hora local.

Alguna manera de sincronizarlo con la hora de los demás países?
"Los errores en programación, siempre están entre la silla y el teclado..."

Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin

Carora, Estado Lara, Venezuela.
User avatar
JoseAlvarez
 
Posts: 726
Joined: Sun Nov 09, 2014 5:01 pm

Re: ¿Cómo saber la fecha de los cambios a una carpeta?

Postby nageswaragunupudi » Mon Mar 04, 2024 5:09 pm

There is another way:
Code: Select all  Expand view
function FolderInfo()

   local oFs   := CreateObject( "Scripting.FileSystemObject" )
   local oFolder  := oFs:GetFolder( "c:\fwh\samples" )

   ? oFolder:DateCreated, oFolder:DateLastModified, oFolder:DateLastAccessed

return nil


You will get your local times.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: ¿Cómo saber la fecha de los cambios a una carpeta?

Postby nageswaragunupudi » Mon Mar 04, 2024 5:21 pm

Time Zone conversions
Here is an example converting our local time to UTC and then NewYork time ( UTC Offset now -5:00 )

Code: Select all  Expand view
function TimeZoneConversions()

   local tDateTimeLocal, tDateTimeUTC, tDateTimeNYC

   tDateTimeLocal := HB_DateTime()  // current time
   tDateTimeUTC   := UTC_TIMESTAMP( tDateTimeLocal )  // FWH function
   tDateTimeNYC   := FW_ADDTIME( tDateTimeUTC, "-05:00:00" )

   ? tDateTimeLocal, tDateTimeUTC, tDateTimeNYC

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: ¿Cómo saber la fecha de los cambios a una carpeta?

Postby nageswaragunupudi » Mon Mar 04, 2024 5:27 pm

Converting time in Spain to my local time in India.
We know the current UTC offset of Spain is +1:00 and India's is +5:30

Code: Select all  Expand view
tsUTC := FW_AddTime( DateTimeSpain. "-01:00:00" )
tsIndia := FW_AddTime( tsUTC, "05:30:00" )
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 84 guests