Create a new file date/de: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 2 | - | ||
| 3 | 1 | Ändert das Erstellungsdatum einer Datei: | |
| 4 | 2 | ||
| 5 | 3 | ``` pascal | |
| 6 | 4 | function funDateiDatumAendern(strDateiname: string; | |
| 7 | 5 | strNeuerZeitstempel: string): boolean; | |
| 8 | 6 | var | |
| 9 | 7 | datNeuesDateidatum: TDateTime; | |
| 10 | 8 | ||
| 11 | 9 | begin | |
| 12 | 10 | ||
| 13 | 11 | Result := False; | |
| 14 | 12 | ||
| 15 | 13 | // Prüft, ob die Datei vorhanden ist | |
| 16 | 14 | if not FileExists(strDateiname) then | |
| 17 | 15 | exit; | |
| 18 | 16 | ||
| 19 | 17 | // legt den aktuellen Datums- und Zeitstempel der Datei fest | |
| 20 | 18 | // Die Schreibweise des Datums richtet sich nach dem Betriebssystem | |
| 21 | 19 | // Die Schreibweise der Uhrzeit richtet sich nach Sommer- und Winterzeit | |
| 22 | 20 | ||
| 23 | 21 | datNeuesDateidatum := StrToDateTime(strNeuerZeitstempel); | |
| 24 | 22 | ||
| 25 | 23 | // StrToTime('03:00') | |
| 26 | 24 | // TryStrToDateTime | |
| 27 | 25 | ||
| 28 | 26 | // Setzt das neue Dateidatum | |
| 29 | 27 | FileSetDate(strDateiname, DateTimeToFileDate(datNeuesDateidatum)); | |
| 30 | 28 | ||
| 31 | 29 | Result := True; | |
| 32 | 30 | ||
| 33 | 31 | end; | |
| 34 | 32 | ``` | |
| 35 | 33 | ||
| 36 | - | ||
| 37 | 34 | Aufruf unter Windows: | |
| 38 | 35 | ||
| 39 | 36 | ``` pascal | |
| 40 | 37 | if not funDateiDatumAendern('E:\Test.txt', '10.01.2000 14:34:56') then | |
| 41 | 38 | ShowMessage('Fehler'); | |
| 42 | 39 | ``` | |
| 43 | 40 | ||
| 44 | - | ||
| 45 | 41 | Aufruf unter Linux (Ubuntu): | |
| 46 | 42 | ||
| 47 | 43 | ``` pascal | |
| 48 | 44 | if not funDateiDatumAendern('/home/user/Dokumente/Test.txt', '10-1-00 14:34:56') then | |
| 49 | 45 | ShowMessage('Fehler'); | |
| 50 | 46 | ``` | |
| 51 | 47 | ||
| 52 | - | ||
| 53 | - | ||
| 54 | 48 | --Olaf 06:44, 19 July 2013 (UTC) | |
| 55 | 49 | ||
| 56 | 50 | --- | |
| 57 | 51 | *From the Free Pascal wiki, page "Create a new file date/de", as it stood on 2020-01-16 after a change by Bart, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 58 | 52 | Category: Code Snippets/de | |
| 59 | 53 | Category: Deutsch |
