Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Uso del SysUtils.FileWrite. ¿Cómo? (https://www.clubdelphi.com/foros/showthread.php?t=70329)

metalfox6383 14-10-2010 20:16:16

Uso del SysUtils.FileWrite. ¿Cómo?
 
Hola:

Quisiera saber cómo utilizo la función SysUtils.FileWrite para escribir en un archivo ya abierto. Tengo delphi 2010.

Gracias.

escafandra 14-10-2010 22:02:14

No se trata de una función de la API de Windows si no una función de delphi:
Cita:

Writes the contents of a buffer to the current position in a file.

Unit

SysUtils

Category

file management routines

Delphi syntax:

function FileWrite(Handle: Integer; const Buffer; Count: Integer): Integer;

C++ syntax:

extern PACKAGE int __fastcall FileWrite(int Handle, const void *Buffer, unsigned Count);

Description

FileWrite writes Count bytes to the file given by Handle from the buffer specified by Buffer. Handle is a file handle returned by the FileOpen or FileCreate method.

The return value is the number of bytes actually written, or -1 if an error occurred.

: Do not mix routines that take or return file handles with those that use Delphi language file variables (typically seen as var F). To write to a file specified by a Delphi file variable, use Write, Writeln, or BlockWrite instead.
Saludos.

metalfox6383 14-10-2010 22:34:23

El texto que acabas de citar ya lo había leído de la documentación del programa. Quisiera que alguien con experiencia con esta función me enseñe a usarla, porque hay varias cosas que no entiendo del texto de ayuda. Como por ejemplo: el Buffer.

Simplemente busco un ejemplo de alguien que ya lo sepa usar.

Gracias.

escafandra 15-10-2010 08:28:20

Código Delphi [-]
var
  hFile: THandle;
begin
  hFile:=  CreateFile('Fichero.txt' , GENERIC_WRITE, 0, nil, OPEN_ALWAYS, FILE_FLAG_WRITE_THROUGH, 0);
  FileWrite(hFile, 'Hola', 4);
  CloseHandle(hFile);
end;

Saludos.

Ñuño Martínez 15-10-2010 10:38:20

Cita:

Empezado por escafandra (Mensaje 379326)
No se trata de una función de la API de Windows si no una función de delphi:

Tienes razón, así que lo he movido a otra sección más adecuada. :)

cloayza 15-10-2010 17:00:23

Mira el enlace hay un ejemplo completo para C++Buider y Delphi...

http://docs.embarcadero.com/products...FileWrite.html

Saludos

!!!Que hariamos sin google!!! :mad:

metalfox6383 15-10-2010 17:40:26

Muchas gracias. Los ejemplos me has sido ilustrativos.


La franja horaria es GMT +2. Ahora son las 07:32:58.

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