selbst kopieren
-
hier ich hab nen codesnippsel gefunde damit sich ein programm an eine andere stelle compiert leider gibt immer fehler :
#include <stdio.h> #include <windows.h> int main(int argc,char *argv[0]) { CopyFile(*argv[0],"C:\\kopie.exe"); }könnt ihr mir helfen
mfg
bob der programmierende Baumeister
-
Ich würde sagen
CopyFile(*argv[0],"C:\\kopie.exe");muss in Wahrheit heißen:
CopyFile(argv[0],"C:\\kopie.exe");Durch das Dereferenzieren nimmt man sonst nur den ersten Buchstaben des Dateipfads...
BTW: Das ist kein Standard-C++ und gehört nicht in dieses Forum.
Felix
-
hmm erster fehler schon mal weg aber Dev-c++ zeigt immernoch :
too few arguments to function `BOOL CopyFileA(const CHAR *, const CHAR *, int)'an
-
Ja, keine Ahnung wofür der letzte Parameter da ist
, aber bei den Seiten, die ich durch googeln gefunden habe, wurde einfach als dritter Parameter 0 übergeben, kannst es ja mal damit probieren:CopyFile(argv[0],"C:\\kopie.exe",0);
-
Es ist immer angebracht, auch eine entsprechende Fehlermeldung mitzuposten - außerdem steht in der Fehlerbeschreibung doch, was das Problem ist.
-
MSDN schrieb:
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.
-
Dieser Thread wurde von Moderator/in HumeSikkins aus dem Forum C++ in das Forum WinAPI verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.