WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

DllCall Information

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

DllCall To GetFileAttributesEx


;BOOL GetFileAttributesEx(
;  LPCTSTR lpFileName,
;  GET_FILEEX_INFO_LEVELS fInfoLevelId,
;  LPVOID lpFileInformation
;)

;WIN32_FILE_ATTRIBUTE_DATA
;The WIN32_FILE_ATTRIBUTE_DATA structure contains attribute information for a file or directory. 
;The GetFileAttributesEx function uses this structure. 

;typedef struct _WIN32_FILE_ATTRIBUTE_DATA {  
;DWORD dwFileAttributes;      (4)
;FILETIME ftCreationTime;     (8)
;FILETIME ftLastAccessTime;   (8)
;FILETIME ftLastWriteTime;    (8)
;DWORD nFileSizeHigh;         (4)
;DWORD nFileSizeLow;          (4)
;} WIN32_FILE_ATTRIBUTE_DATA, *LPWIN32_FILE_ATTRIBUTE_DATA;

file = "C:\windows\notepad.exe"

bufsize = 36
lpFileInformation = BinaryAlloc( bufsize )
BinaryEodSet( lpFileInformation, bufsize )
dllname = StrCat( Dirwindows(1), "kernel32.dll" )
attr = DllCall( dllname, long:"GetFileAttributesExA",lpstr:file, long:0, lpbinary:lpFileInformation )
if attr == 0
   Message( "GetFileAttributesExA Error", DllLastError() )
   BinaryFree( lpFileInformation )
   exit
endif

 
;BOOL FileTimeToSystemTime(
;	const FILETIME* lpFileTime,
;	LPSYSTEMTIME lpSystemTime)

lpdatebuffer = BinaryAlloc(8)
BinaryCopy( lpdatebuffer, 0, lpFileInformation, 12, 8)

bufsize = 16
lpSystemTime = BinaryAlloc( bufsize )

ret = DllCall( dllname, long:"FileTimeToSystemTime", lpbinary:lpdatebuffer, lpbinary:lpSystemTime )
if ret == 0
    Message("FileTimeToSystemTime Error",DllLastError())
	 BinaryFree(lpdatebuffer)
	 BinaryFree(lpSystemTime)
    exit
endif

year = BinaryPeek2(lpSystemTime,0)
month = StrFixLeft(BinaryPeek2(lpSystemTime,2),"0",2)
day = StrFixLeft(BinaryPeek2(lpSystemTime,4),"0",2)
hours = StrFixLeft(BinaryPeek2(lpSystemTime,6),"0",2)
minutes = StrFixLeft(BinaryPeek2(lpSystemTime,8),"0",2)
seconds = StrFixLeft(BinaryPeek2(lpSystemTime,10),"0",2)

ymdhms = StrCat(year,":",month,":",day,":",hours,":",minutes,":",seconds)
Message(StrCat("LastAccessTime: ",file), ymdhms)


BinaryFree( lpFileInformation )
BinaryFree( lpdatebuffer )
BinaryFree( lpSystemTime )
exit


Article ID:   W16950
File Created: 2007:07:03:14:27:10
Last Updated: 2007:07:03:14:27:10