Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   API de Windows (https://www.clubdelphi.com/foros/forumdisplay.php?f=7)
-   -   writefile y FileWrite en delphi xe6 (https://www.clubdelphi.com/foros/showthread.php?t=86182)

ebeltete 27-06-2014 17:46:13

writefile y FileWrite en delphi xe6
 
Amigos del foro, estoy probando Delphi XE6 y trabajando con una aplicacion para leer el idtag de los archivos de mp3. En DElhi5 y Windows XP me funcionaba a la perfeccion, pero al querer hacerlo en Delphi XE6 y Windows 7, no logro hacerlo funcionar.
Con el siguiente codigo tendria que poder grabar los datos en el archivo, pero no logro hacerlo.
Código Delphi [-]
  
  FTagRecord: ID3Struct;

const
  ID3Magic = 'TAG';

 ID3Struct = packed record
    Magic:   Array [0..2 ] of ansiChar;
    Title:   Array [0..29] of ansiChar;
    Artist:  Array [0..29] of ansiChar;
    Album:   Array [0..29] of ansiChar;
    Year:    Array [0..3] of ansiChar;
    Comment: Array [0..29] of ansiChar;
    Genre:   ID3Genre;
  end;



  FillChar(FTagRecord, SizeOf(FTagRecord), ' ');
    with FTagRecord do
    begin
      StrMove(Magic, ID3Magic, SizeOf(Magic));

      s := PadSpace(FTitle, SizeOf(Title));
      StrMove(Title, pansiChar(s), Length(s));

      s := PadSpace(FArtist, SizeOf(Artist));
      StrMove(Artist, pansiChar(s), Length(s));

      s := PadSpace(FAlbum, SizeOf(Album));
      StrMove(Album, pansiChar(s), Length(s));

      s := PadSpace(FYear, SizeOf(Year));
      StrMove(Year, pansiChar(s), Length(s));

      s := PadSpace(FComment, SizeOf(Comment));
      StrMove(Comment, pansiChar(s), Length(s));

      Genre := ID3NameToGenre(FGenre);

    end;
 hFile := createfile(pchar(FFileName), GENERIC_WRITE or GENERIC_READ , FILE_SHARE_WRITE+FILE_SHARE_READ,nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL   , 0);
            SetFilePointer(hFile,GETFILESIZE(hFile,nil)-SizeOf(FTagRecord), NIL, FILE_BEGIN);

        if   sysutils.FileWrite(hFile, FTagRecord, SizeOf(FTagRecord))=-1 then
            showmessage('Atención! No se pudo grabar la información.');
         Closehandle(hFile);

escafandra 10-07-2014 20:14:41

¿Y qué error te da?

Piosiblemente se trata del unicode. Prueba esto:
Código Delphi [-]
 hFile := CreateFile(PWCHAR(FFileName), .......)

O esto:
Código Delphi [-]
 
 hFile := CreateFileA(PCHAR(FFileName), ...


Saludos.


La franja horaria es GMT +2. Ahora son las 00:05:35.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi