Hola lucila89.
Te hice un ejemplo básico donde se utilizan las funciones que solicitas:
Código Delphi
[-]
...
const
FILE_NAME = 'C:\PRUEBA.TXT';
var
Hnd: Integer;
stToRead, stToWrite: string;
NR,NW: LongWord;
begin
Hnd:= CreateFile(FILE_NAME, GENERIC_WRITE, FILE_SHARE_DELETE,
nil, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
if Hnd = INVALID_HANDLE_VALUE then
raise Exception.Create('Error creando archivo')
else
begin
Readfile(Hnd, stToRead, Length(stToRead), NR, nil); stToWrite:= 'PRUEBA_DE_ESCRITURA_CON_WINDOWS_API';
WriteFile(Hnd, stToWrite[1], Length(stToWrite), NW, nil);
CloseHandle(Hnd);
if MessageBox(Handle,'¿ BORRA EL ARCHIVO ?','',MB_ICONQUESTION + MB_YESNO) = IDYES then
Windows.DeleteFile(FILE_NAME)
end;
end;
Es sólo un código trivial que crea/abre, lee, escribe, cierra y borra. Si querés más detalles sobre el uso de las funciones,
te dejo los enlaces con la información:
CreateFile Function ,
CloseHandle Function ,
DeleteFile Function ,
ReadFile Function ,
WriteFile Function
Un saludo.