Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Copyfile unter win98 funktioniert nicht? (https://www.delphipraxis.net/50571-copyfile-unter-win98-funktioniert-nicht.html)

Grolle 27. Jul 2005 20:05


Copyfile unter win98 funktioniert nicht?
 
Hallo!
Folgender Code funktioniert nur unter win98 nicht:
Delphi-Quellcode:
copyfile(PChar(pfad +'\einstellungen.txt'),PChar((ExtractFilePath(ParamStr(0))+ '\daten\einstellungen.txt')),false);
Wodran liegt das und kann man das irgendwie lösen?

supermuckl 27. Jul 2005 20:08

Re: Copyfile unter win98 funktioniert nicht?
 
eventuell werden nur 8+3 dateinamen längen unterstützt ?!

evtl mal mit der console schauen wie die datei in der schwarzen box heist und den namen mal probieren.
ansonsten evtl zuviele oder zuwenige \ oder /

Daniel G 27. Jul 2005 20:12

Re: Copyfile unter win98 funktioniert nicht?
 
Das sagt das PSDK dazu

CopyFile

The CopyFile function copies an existing file to a new file.

The CopyFileEx function provides two additional capabilities. CopyFileEx can call a specified callback function each time a portion of the copy operation is completed, and CopyFileEx can be canceled during the copy operation.


BOOL CopyFile(
LPCTSTR lpExistingFileName,
LPCTSTR lpNewFileName,
BOOL bFailIfExists
);

Parameters
lpExistingFileName
[in] Pointer to a null-terminated string that specifies the name of an existing file.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.


Windows Me/98/95: This string must not exceed MAX_PATH characters.


lpNewFileName
[in] Pointer to a null-terminated string that specifies the name of the new file.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.


Windows Me/98/95: This string must not exceed MAX_PATH characters.


bFailIfExists
[in] If this parameter is TRUE and the new file specified by lpNewFileName already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
Security attributes for the existing file are not copied to the new file. To copy security attributes, use the SHFileOperation function.

File attributes for the existing file are copied to the new file. For example, if an existing file has the FILE_ATTRIBUTE_READONLY file attribute, a copy created through a call to CopyFile will also have the FILE_ATTRIBUTE_READONLY file attribute. For more information, see Retrieving and Changing File Attributes.

This function fails with ERROR_ACCESS_DENIED if the destination file already exists and has the FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_READONLY attribute set.


When CopyFile is used to copy an encrypted file, it attempts to encrypt the destination file with the keys used in the encryption of the source file. If this cannot be done, this function attempts to encrypt the destination file with default keys, as in Windows 2000. If both of these methods cannot be done, CopyFile fails with an ERROR_ENCRYPTION_FAILED error code.


Windows 2000: When CopyFile is used to copy an encrypted file, the function attempts to encrypt the destination file with the default keys. No attempt is made to encrypt the destination file with the keys used in the encryption of the source file. If it cannot be encrypted, CopyFile completes the copy operation without encrypting the destination file.





Windows Me/98/95: CopyFileW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.


Example Code
For an example, see Searching for Files and Changing File Attributes.

Requirements
Client: Included in Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, and Windows 95.
Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server.
Unicode: Implemented as Unicode and ANSI versions. Note that Unicode support on Windows Me/98/95 requires Microsoft Layer for Unicode.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.


See Also
File Management Functions, CopyFileEx, CreateFile, MoveFile




Hilft dir das evtl.? Wie lang ist denn eigentlich MAX_PATH?

Grolle 27. Jul 2005 20:22

Re: Copyfile unter win98 funktioniert nicht?
 
Hallo!
Das komische ist, dass es wohl teilweise an den Dateien liegt.
Die Textdateien werden kopiert. Das ganze ist ne Funktion zur
Wiederherstellung einer Datenbank. Hier nochmal der ganze Code:
Delphi-Quellcode:
procedure TForm1.Wiederherstellen1Click(Sender: TObject);
var
pfad : string;

begin
  SelectDirectory('Bitte Ordner auswählen:', '' ,pfad);

  if MessageDlg('    Achtung die Datenbank wird wiederhergestellt!      ' + #13#10 +
                '    Alle vorhandenen Daten werden hiermit gelöscht!    ',mtWarning,[mbOk, mbCancel],0)
  = mrok then
  begin
    copyfile(PChar(pfad +'\adressen.adi'),PChar((ExtractFilePath(ParamStr(0))+ '\daten\adressen.adi')),false);
    copyfile(PChar(pfad +'\adressen.adt'),PChar((ExtractFilePath(ParamStr(0))+ '\daten\adressen.adt')),false);
    copyfile(PChar(pfad +'\einstellungen.txt'),PChar((ExtractFilePath(ParamStr(0))+ '\daten\einstellungen.txt')),false);
    copyfile(PChar(pfad +'\gruppen.txt'),PChar((ExtractFilePath(ParamStr(0))+ '\daten\gruppen.txt')),false);
    MessageDlg('    Die Wiederherstellung der Datenbank war erfolgreich!     ' + #13#10 +
               '    Bitte starten sie die Anwendung neu!                     ' ,mtInformation,[mbOK],0);
  end;
end;
:gruebel:

Olli 27. Jul 2005 21:07

Re: Copyfile unter win98 funktioniert nicht?
 
Zitat:

Zitat von Daniel G
Hilft dir das evtl.? Wie lang ist denn eigentlich MAX_PATH?

Aktuell
#define MAX_PATH 260

@Grolle: Hast du Rechte auf die Dateien?

Übrigens ist CopyFile() eine API-Funktion!

DP-Maintenance 27. Jul 2005 21:09

DP-Maintenance
 
Dieses Thema wurde von "alcaeus" von "Object-Pascal / Delphi-Language" nach "Windows API / MS.NET Framework API" verschoben.
Zitat:

Zitat von Olli
Übrigens ist CopyFile() eine API-Funktion!

Und deswegen gehoert es auch in die API-Sparte ;)

Grolle 27. Jul 2005 21:35

Re: Copyfile unter win98 funktioniert nicht?
 
Hallo!
Ich nehme an MAX_PAth ist die maximale Länge des Pfades.
Muss ich diese denn definieren? Diese ist von User zu User
unterschiedlich.

@ Olli
Eigentlich werden diese Dateien vorher als kompletter
Ordner kopiert und so müsste ich doch wieder darauf
zugreifen können?

Zitat:

Übrigens ist CopyFile() eine API-Funktion!
Hab mich verirrt :stupid:

Daniel G 27. Jul 2005 21:41

Re: Copyfile unter win98 funktioniert nicht?
 
Zitat:

Zitat von Grolle
Hallo!
Ich nehme an MAX_PAth ist die maximale Länge des Pfades.
Muss ich diese denn definieren? Diese ist von User zu User
unterschiedlich.

Nee, die ist schon definiert. Ist eine Konstante von Windows. Der obige Ausschnitt aus dem PSDK verrät dir etwas über den Zusammenhang von MAX_PATH und Copyfile unter Windows 95/98.

Olli 27. Jul 2005 21:45

Re: Copyfile unter win98 funktioniert nicht?
 
Zitat:

Zitat von Grolle
@ Olli
Eigentlich werden diese Dateien vorher als kompletter
Ordner kopiert und so müsste ich doch wieder darauf
zugreifen können?

Hmm? Ordner kopieren? Wie? Aber doch nicht mit CopyFile. Mehr Input bitte ;)

Grolle 27. Jul 2005 21:53

Re: Copyfile unter win98 funktioniert nicht?
 
Zitat:

To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path.
Also muss ich \\?\ voranstellen, um den String auf 767 Zeichen zu erweitern?

@ Olli
Der Ordner wird kopiert mit einer eigenen Funktion. Leider habe
ich den Quelltext jetzt nicht hier. Der Ordner wird auf jeden
Fall an einem vom Nutzer definierten Pfad gespeichert und
in Datumsform benannt (27072005). Später soll der Nutzer (s. Code weiter oben)
den Sicherungsordner auswählen und die DB-relevanten Dateien
werden in den Ordner mit der .exe (+/daten) zurückkopiert
und vorhandene Dateien werden überschrieben.
Wie gesagt unter 2000 und xp klappt es.
Unter 98 klappt es nur mit den txt-Dateien?!


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:57 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz