by 卓漏 » 2006年7月28日(金) 21:36
下のような、プログラムを作って、エラーもなく動作するのですが、
なぜか、作成日時の時間の部分が、実際とずれてしまっています。
どこか、間違っている部分とかあるでしょうか?
コード: 全て選択
Function GetFileCreationTime(fileNumber As Integer) As String
'+ ファイルの作成日時を取得します +
Dim Str As String
Dim fileFDT As FILETIME
Dim fileSDT As SYSTEMTIME
GetFileTime(fileData(fileNumber).hFile, fileFDT, ByVal NULL, ByVal NULL)
FileTimeToSystemTime(fileFDT, fileSDT)
Str = Str$(fileSDT.wYear) & "/" & Str$(fileSDT.wMonth) & "/" & Str$(fileSDT.wDay)
Str = Str & " " & Str$(fileSDT.wHour) & ":" & Str$(fileSDT.wMinute) & ":" & Str$(fileSDT.wSecond)
GetFileCreationTime = Str
End Function
ちなみに、「fileData(fileNumber).hFile」は、
コード: 全て選択
fileData(fileNumber).hFile = CreateFile(pFilePath, GENERIC_READ + GENERIC_WRITE, 0, ByVal NULL, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, NULL)
となっています。
下のような、プログラムを作って、エラーもなく動作するのですが、
なぜか、作成日時の時間の部分が、実際とずれてしまっています。
どこか、間違っている部分とかあるでしょうか?
[code]
Function GetFileCreationTime(fileNumber As Integer) As String
'+ ファイルの作成日時を取得します +
Dim Str As String
Dim fileFDT As FILETIME
Dim fileSDT As SYSTEMTIME
GetFileTime(fileData(fileNumber).hFile, fileFDT, ByVal NULL, ByVal NULL)
FileTimeToSystemTime(fileFDT, fileSDT)
Str = Str$(fileSDT.wYear) & "/" & Str$(fileSDT.wMonth) & "/" & Str$(fileSDT.wDay)
Str = Str & " " & Str$(fileSDT.wHour) & ":" & Str$(fileSDT.wMinute) & ":" & Str$(fileSDT.wSecond)
GetFileCreationTime = Str
End Function
[/code]
ちなみに、「fileData(fileNumber).hFile」は、
[code]
fileData(fileNumber).hFile = CreateFile(pFilePath, GENERIC_READ + GENERIC_WRITE, 0, ByVal NULL, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, NULL)
[/code]
となっています。