해당 파일의 File 생성,최종access,최종Write 날짜를 가져올 수 있는
간단한 방법입니다.
** Structure
global type s_filetime from structure
unsignedlong lowdate
unsignedlong highdate
end type
global type s_systemtime from structure
unsignedinteger wyear
unsignedinteger wmonth
unsignedinteger wdayofweek
unsignedinteger wday
unsignedinteger whour
unsignedinteger wminute
unsignedinteger wsecond
unsignedinteger wmilliseconds
end type
**Global External Function
// File related API functions
Function boolean GetFileTime(ulong hFile, ref s_filetime aCreated, ref s_filetime aAccess, ref s_filetime aWrite) library "kernel32.dll"
Function boolean CloseHandle(ulong hFile) library "kernel32.dll"
Function long CreateFileA(ref string fname, ulong dwAccess, ulong dwShare, ref string lpSecurity, ulong dwCreate, ulong dwFlags, ulong fHandle) library "kernel32.dll"
Function boolean FileTimeToSystemTime(ref s_filetime lptFile, ref s_systemtime lptSystem) library "kernel32.dll"
Function boolean FileTimeToLocalFileTime(ref s_filetime lptFile, ref s_filetime lptLocalFile) library "kernel32.dll"
** Function
global type f_getmodifieddate from function_object
end type
forward prototypes
global function datetime f_getmodifieddate (string asfname)
end prototypes
global function datetime f_getmodifieddate (string asfname);
s_filetime lFtCreate, lFtLastAccess, lFtLastWrite, lFtLocalTime
s_systemtime lFtST // system time
string lsNull, lsTemp
Long hFile
Date ldtWrite
Time ltmWrite
// GetFileTime을 하기 위해서는 GENERIC_READ Mode로 Open해야 한다.
uLong GENERIC_READ = 2147483648 // 0x80000000
uLong GENERIC_WRITE = 1073741824 // 0x40000000
uLong FILE_SHARE_READ = 1
uLong FILE_SHARE_WRITE = 2
uLong OPEN_EXISTING = 3
SetNull(lsNull)
// Open File
hFile = CreateFileA(asFname, GENERIC_READ, FILE_SHARE_READ + FILE_SHARE_WRITE, lsNull, &
OPEN_EXISTING, 0, 0)
IF hFile >= 0 THEN
// File 생성,최종access,최종Write
GetFileTime(hFile, lFtCreate, lFtLastAccess, lFtLastWrite)
CloseHandle(hFile)
// File 최종Write 시간을 Local(한국)시간으로 변경한다.
FileTimeToLocalFileTime(lFtLastWrite, lFtLocalTime)
// Long type의 날짜 -> SystemTime 포맷
IF FileTimeToSystemTime(lFtLocalTime, lFtST) THEN
lsTemp = string(lFtST.wYear, "0000") + "/" + string(lFtST.wMonth, "00") + &
"/" + string(lFtST.wDay, "00")
ldtWrite = Date(lsTemp)
lsTemp = string(lFtST.wHour, "00") + ":" + string(lFtST.wMinute, "00") + &
":" + string(lFtST.wSecond, "00")
ltmWrite = Time(lsTemp)
Return DateTime(ldtWrite, ltmWrite)
END IF
END IF
Return DateTime(Date("1990/01/01"), Time("00:00:00"))
end function
추가한 첨부파일 이용하세요.
♥도움 되셨다면 ♥ 공감 부탁드려요~~
//.............<끝>
'PowerBuilder' 카테고리의 다른 글
오라클을 이용한 정기적인 메일 전송 (0) | 2023.07.28 |
---|---|
Powerbuilder datawindow runtime(PBD, DLL)일때 느린현상이 나타날때(DisableBind=1) (0) | 2023.06.16 |
파워빌더에서 오라클 alter명령 실행하기 (0) | 2023.06.15 |
Powerbuilder datawindow is very slow (0) | 2023.06.13 |