был создан?

MSDN Library Visual Studio 6.0 писал(а):GetAttr Function
Returns an Integer representing the attributes of a file, directory, or folder.
Syntax
GetAttr(pathname)
The required pathnameargument is astring expression that specifies a file name. The pathname may include the directory or folder, and the drive.
Return Values
The value returned by GetAttr is the sum of the following attribute values:
Constant_______Value___Description
vbNormal________0_________Normal.
vbReadOnly______1________Read-only.
vbHidden________2________Hidden.
vbSystem________4________System file.
vbDirectory______16_______Directory or folder.
vbArchive________32_______File has changed since last backup.
Note Theseconstants are specified by Visual Basic for Applications. The names can be used anywhere in your code in place of the actual values.
Remarks
To determine which attributes are set, use the And operator to perform abitwise comparison of the value returned by the GetAttr function and the value of the individual file attribute you want. If the result is not zero, that attribute is set for the named file. For example, the return value of the following And expression is zero if the Archive attribute is not set:
- Код: Выделить всё
Result = GetAttr(FName) And vbArchive
A nonzero value is returned if the Archive attribute is set.
MSDN Library Visual Studio 6.0 писал(а):GetAttr Function Example
This example uses the GetAttr function to determine the attributes of a file and directory or folder.
- Код: Выделить всё
Dim MyAttr
' Assume file TESTFILE has hidden attribute set.
MyAttr = GetAttr("TESTFILE") ' Returns 2.
' Returns nonzero if hidden attribute is set on TESTFILE.
Debug.Print MyAttr And vbHidden
' Assume file TESTFILE has hidden and read-only attributes set.
MyAttr = GetAttr("TESTFILE") ' Returns 3.
' Returns nonzero if hidden attribute is set on TESTFILE.
Debug.Print MyAttr And (vbHidden + vbReadOnly)
' Assume MYDIR is a directory or folder.
MyAttr = GetAttr("MYDIR") ' Returns 16.
shkot писал(а):А FName - это типа "С:\666\444\33.exe" или "33.exe" или "33"
вот как и надо было писать в первом вопросе, а не править пост после того, как на него уже ответилиshkot писал(а):Ага, и чё мне с этого "32" ? Мне нужно знать точную дату
создания/изменения!
Private Const OPEN_EXISTING = 3
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Private Type BY_HANDLE_FILE_INFORMATION
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
dwVolumeSerialNumber As Long
nFileSizeHigh As Long
nFileSizeLow As Long
nNumberOfLinks As Long
nFileIndexHigh As Long
nFileIndexLow As Long
End Type
Private Declare Function GetFileInformationByHandle Lib "kernel32" (ByVal hFile As Long, lpFileInformation As BY_HANDLE_FILE_INFORMATION) As Long
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Any, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@allapi.net
Dim hFile As Long, FileInfo As BY_HANDLE_FILE_INFORMATION
'create a handle to the file 'c:\autoexec.bat'
hFile = CreateFile("c:\autoexec.bat", 0, 0, ByVal 0&, OPEN_EXISTING, 0, ByVal 0&)
'retrieve the file information
GetFileInformationByHandle hFile, FileInfo
'close the handle
CloseHandle hFile
'show the result
MsgBox "File size: " + CStr(FileInfo.nFileSizeLow), vbInformation
End Sub
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As Long
Private Declare Function FileTimeToLocalFileTime Lib "kernel32" (lpFileTime As FILETIME, lpLocalFileTime As FILETIME) As Long
Option Explicit
Private Const OPEN_EXISTING = 3
Private Type FileTime
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Private Type BY_HANDLE_FILE_INFORMATION
dwFileAttributes As Long
ftCreationTime As FileTime
ftLastAccessTime As FileTime
ftLastWriteTime As FileTime
dwVolumeSerialNumber As Long
nFileSizeHigh As Long
nFileSizeLow As Long
nNumberOfLinks As Long
nFileIndexHigh As Long
nFileIndexLow As Long
End Type
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Declare Function GetFileInformationByHandle Lib "kernel32" (ByVal hFile As Long, lpFileInformation As BY_HANDLE_FILE_INFORMATION) As Long
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Any, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FileTime, lpSystemTime As SYSTEMTIME) As Long
Private Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@allapi.net
Dim hFile As Long, FileInfo As BY_HANDLE_FILE_INFORMATION
Dim FileTime As SYSTEMTIME
'create a handle to the file 'c:\autoexec.bat'
hFile = CreateFile("c:\autoexec.bat", 0, 0, ByVal 0&, OPEN_EXISTING, 0, ByVal 0&)
'retrieve the file information
GetFileInformationByHandle hFile, FileInfo
'close the handle
CloseHandle hFile
'show the result
MsgBox "File size: " + CStr(FileInfo.nFileSizeLow), vbInformation
FileTimeToSystemTime FileInfo.ftCreationTime, FileTime
MsgBox "File created by:" & CStr(FileTime.wDay) & "." & CStr(FileTime.wMonth) & "." & CStr(FileTime.wYear)
End Sub
проще... но функция FileDateTime возвращает дату и время последней модификации файла, а человек спрашивал про дату создания файла (а это несколько разные вещи)SeRRg писал(а):А не проще ли?
izm = FileDateTime(puti)
Call MsgBox("Файл изменен: " & izm, , "Text Recover")
И если это не то, то в чем отличие?
shkot писал(а):Что касается БОЛЬШОЙ проги, то wHour почему - то не то число выдает. Однако, wMilliseconds
- это Вы очень круто загнули!!!...
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 14