Dear Mr. Otto
Can you show me how to add GetFileAttributesEx from WINDOWS API.
#include "fivewin.ch"
//----------------------------------------------------------------------------//
function Main()
local cFile := "tutor01.prg"
local hInfo
SET DATE GERMAN
SET CENTURY ON
SET TIME FORMAT TO "HH:MM:SS"
hInfo := GetFileAttributesEx( cFile )
? "FileSize", hInfo[ "FileSize" ]
XBROWSER hInfo AUTOFIT
return nil
//----------------------------------------------------------------------------//
function GetFileAttributesEx( cFile )
local aRet
local hRet := {=>}
if File( cFile )
aRet := FILEATTRIBEX( TrueName( cFile ) )
hRet[ "FileSize" ] := aRet[ 1 ]
hRet[ "Updated" ] := aRet[ 2 ]
hRet[ "Created" ] := aRet[ 3 ]
hRet[ "LastAccessed" ] := aRet[ 4 ]
#ifdef __XHARBOUR__
HSetCaseMatch( hRet, .f. )
#else
HB_HSetCaseMatch( hRet, .f. )
#endif
endif
return hRet
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#include <hbdate.h>
#include <fwh.h>
static double hbdatetime( FILETIME fTime )
{
FILETIME localFileTime;
SYSTEMTIME systemTime;
#ifdef __XHARBOUR__
long lDate, lTime;
int iOk;
#endif
double hbdt = 0.0;
if ( FileTimeToLocalFileTime( &fTime, &localFileTime ) &&
FileTimeToSystemTime( &localFileTime, &systemTime ) )
{
#ifdef __XHARBOUR__
hb_datetimeEncode( &lDate, &lTime, systemTime.wYear, systemTime.wMonth,
systemTime.wDay, systemTime.wHour, systemTime.wMinute,
( double ) systemTime.wSecond, 0, &iOk );
hbdt = hb_datetimePack( lDate, lTime );
#else
hbdt = hb_timeStampPackD( systemTime.wYear, systemTime.wMonth,
systemTime.wDay, systemTime.wHour, systemTime.wMinute,
systemTime.wSecond );
#endif
}
return ( hbdt );
}
HB_FUNC_STATIC( FILEATTRIBEX )
{
WIN32_FILE_ATTRIBUTE_DATA fileAttributeData;
if ( GetFileAttributesEx( hb_parc( 1 ), GetFileExInfoStandard, &fileAttributeData ) )
{
FILETIME localFileTime;
SYSTEMTIME systemTime;
LARGE_INTEGER fileSize;
double tDate;
fileSize.LowPart = fileAttributeData.nFileSizeLow;
fileSize.HighPart = fileAttributeData.nFileSizeHigh;
hb_reta( 4 );
#ifdef __XHARBOUR__
hb_stornll( ( LONGLONG ) fileSize.QuadPart, -1, 1 );
hb_stordtd( hbdatetime( fileAttributeData.ftLastWriteTime ) , -1, 2 );
hb_stordtd( hbdatetime( fileAttributeData.ftCreationTime ) , -1, 3 );
hb_stordtd( hbdatetime( fileAttributeData.ftLastAccessTime ) , -1, 4 );
#else
hb_storvnll( fileSize.QuadPart, -1, 1 );
hb_storvtd( hbdatetime( fileAttributeData.ftLastWriteTime ) , -1, 2 );
hb_storvtd( hbdatetime( fileAttributeData.ftCreationTime ) , -1, 3 );
hb_storvtd( hbdatetime( fileAttributeData.ftLastAccessTime ) , -1, 4 );
#endif
} else { hb_ret(); }
}
#pragma ENDDUMP