Announcement

Collapse
No announcement yet.

CopyFile

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • CopyFile

    Hallo!

    Weiss hier jemand wie das mit dem CopyFile funktionieren soll? Wenn ich versuche eine Datei irgendwo hinzukopieren, dann passiert nichts. Ein Beispiel wäre nicht schlecht.

    Gruß:

    Tobias

  • #2
    <html>

    <head>
    <meta http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1">
    <meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
    <title>Normale Seite ohne Titel</title>
    </head>

    <body bgcolor="#FFFFFF">

    <p>Hallo Tobias, hier die Kopierfunktion aus einem meiner
    Programme. </p>

    <pre>
    int __fastcall TMainForm::Kopieren(char *Quelle, char *Ziel)
    {
    int Err=0;
    Err=CopyFile(Quelle,Ziel,FALSE);
    if(!Err)
    {
    LPVOID lpMsgBuf;
    LPSTR ErrorString=new char[80];
    Err=GetLastError();
    sprintf(ErrorString,&quot;Fehler Nr %d:&quot;,Err);
    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER ,
    FORMAT_MESSAGE_FROM_SYSTEM,
    NULL,Err,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
    (LPTSTR) &amp;lpMsgBuf,0,NULL);
    ShowMessage(ErrorString);
    ShowMessage((char *)lpMsgBuf));
    delete ErrorString;
    LocalFree( lpMsgBuf );
    }
    return(!Err);
    }</pre>

    <p>&nbsp;</p>

    Gruß - Günther

    </body>
    </html&gt
    Günther

    Comment


    • #3
      ... aber irgendwie funktioniert dein Source nicht so ganz.
      Jede menge Fehlermeldungen.
      Ich poste hier mal die Fehlermeldungen.


      [C++ Error] Unit1.cpp(176): E2034 Cannot convert 'int' to 'const void *'.
      [C++ Error] Unit1.cpp(176): E2343 Type mismatch in parameter 'lpSource' in call to '__stdcall FormatMessageA(unsigned long,const void *,unsigned long,unsigned long,char *,unsigned long,void * *)'.
      [C++ Error] Unit1.cpp(176): E2034 Cannot convert 'int' to 'char *'.
      [C++ Error] Unit1.cpp(176): E2343 Type mismatch in parameter 'lpBuffer' in call to '__stdcall FormatMessageA(unsigned long,const void *,unsigned long,unsigned long,char *,unsigned long,void * *)'.
      [C++ Error] Unit1.cpp(176): E2034 Cannot convert 'char *' to 'unsigned long'.
      [C++ Error] Unit1.cpp(176): E2343 Type mismatch in parameter 'nSize' in call to '__stdcall FormatMessageA(unsigned long,const void *,unsigned long,unsigned long,char *,unsigned long,void * *)'.
      [C++ Error] Unit1.cpp(176): E2227 Extra parameter in call to __stdcall FormatMessageA(unsigned long,const void *,unsigned long,unsigned long,char *,unsigned long,void * *).
      [C++ Warning] Unit1.cpp(180): W8013 Possible use of 'lpMsgBuf' before definition.

      Weisst du einen rat?

      Gruß:

      Tobia

      Comment


      • #4
        Wie sieht die Zeile 176 aus
        Günther

        Comment


        • #5
          FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
          NULL,Err,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
          (LPTSTR) &lpMsgBuf,0,NULL);

          War das die Zeile ? Da hatte ich beim Formatieren fürs Forum ein Zeichen zuvielgelöscht und versehentlich falsch korrigiert. Statt Komma ein Oder. Sorry
          Günther

          Comment


          • #6
            HI!

            Vielen Dank für DEINE Hilfe!! Es funktioniert jetzt!!

            Gruß:

            Tobia

            Comment

            Working...
            X