将图片文件的创建时间读入数据库(100分)

  • 主题发起人 主题发起人 freecobra
  • 开始时间 开始时间
F

freecobra

Unregistered / Unconfirmed
GUEST, unregistred user!
我是一个delphi初学者,可以说一点编程基础都没有。<br>我现在要做一个软件,其中我要用一个按钮实现一下功能:<br>在一个目录下有多张图片,我要将目录中的所有图片的创建时间读入数据库中,<br>(图片名称不固定)然后将图片更名后考入另一个目录
 
提供源碼, 可以搜尋指定目錄下的所有檔案(包含子目錄), 至於其它的, 你應有辦法完成<br>如果讀取檔案的存取時間, 可以讀取FileRec.FindData.ftCreationTime為創建時間;<br>FileRec.FindData.ftLastAccessTime為最後讀取時間;<br>FileRec.FindData.ftLastWriteTime為最後寫入時間<br>不過以上為系統檔案時間格式, 可用以下程式轉換為Delphi的TDateTime<br><br>function FileTimeToDateTime(const FileTime: _FILETIME): TDateTime;<br>&nbsp; var<br>&nbsp; &nbsp; SystemTime: TSystemTime;<br>begin<br>&nbsp; FileTimeToSystemTime(FileTime, SystemTime);<br>&nbsp; Result := SystemTimeToDateTime(SystemTime);<br>end;<br><br>function CheckSearch(ReturnCode: DWORD): boolean;<br>var<br>&nbsp; Error: EWin32Error;<br>begin<br>&nbsp; Case ReturnCode of<br>&nbsp; &nbsp; ERROR_SUCCESS: Result := True;<br>&nbsp; &nbsp; ERROR_FILE_NOT_FOUND, ERROR_NO_MORE_FILES, ERROR_PATH_NOT_FOUND: Result := False;<br>&nbsp; &nbsp; else begin<br>&nbsp; &nbsp; &nbsp; Error := EWin32Error.CreateResFmt(@SWin32Error, [ReturnCode,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SysErrorMessage(ReturnCode)]);<br>&nbsp; &nbsp; &nbsp; Error.ErrorCode := ReturnCode;<br>&nbsp; &nbsp; &nbsp; raise Error;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>end;<br><br>procedure SearchFiles(SourcePath: string);<br><br>&nbsp; function AcceptFile(const FileName: string): boolean;<br>&nbsp; begin<br>&nbsp; &nbsp; Result := True; //用來判斷找到的檔案, 是否為想要圖形檔, 可以附檔名來判斷<br>&nbsp; end;<br><br>&nbsp; procedure SearchFile(Path: string);<br>&nbsp; &nbsp; var<br>&nbsp; &nbsp; &nbsp; sName: string;<br>&nbsp; &nbsp; &nbsp; FileRec: TSearchRec;<br>&nbsp; begin<br>&nbsp; &nbsp; Path := IncludeTrailingBackslash(Path);<br>&nbsp; &nbsp; if CheckSearch(FindFirst(Path+'*.*', faAnyFile, FileRec)) then<br>&nbsp; &nbsp; &nbsp; repeat<br>&nbsp; &nbsp; &nbsp; &nbsp; if ((FileRec.Attr and faDirectory) = faDirectory) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (FileRec.Name[1] &lt;&gt; '.') then SearchFile(Path + FileRec.Name);<br>&nbsp; &nbsp; &nbsp; &nbsp; end else begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sName := Path + FileRec.Name;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if AcceptFile(sName) then <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //找到檔案, 做你想要處理<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; until not CheckSearch(FindNext(FileRec));<br>&nbsp; end;<br><br>begin<br>&nbsp; SearchFile(SourcePath);<br>end;
 
刚刚down了一个,你可以试试。<br>http://www.palm5x.com/download/list.asp?ID=887<br><br>其实SmartDraw也不错呀,体积又小。<br>=======<br>抱歉!贴错地方了!
 
学习! 收藏!~
 
感谢lorderic,你的答案对我帮助很大。
 
后退
顶部