Visual Basic - Archivos

Life is soft - evento anual de software empresarial
 
Vista:

Archivos

Publicado por Federico (54 intervenciones) el 17/04/2006 19:07:51
Hola necesito abrir un archivo en modo append, pero sin la sintaxis tradicional de vbasic
sino con la funcion del kernel CreateFile, yo solo puedo abrirlo en forma de lectura o escritura o ambas a la ves pero no en modo append!!

Muchas Gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Archivos

Publicado por Federico (54 intervenciones) el 21/04/2006 14:43:45
Bueno he logrado abrir el archivo en forma del tipo APPEND
aqui va el codigo:

Public Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type

Public Const FILE_APPEND_DATA As Long = &H4
Public Const FILE_END = 2
Public Const OPEN_ALWAYS = 4
Public Const FILE_ATTRIBUTE_NORMAL = &H80
Public Const INVALID_HANDLE_VALUE = -1
Public Declare Function SetFilePointer Lib "kernel32" (ByVal hFile As Long, ByVal lDistanceToMove As Long, lpDistanceToMoveHigh As Long, ByVal dwMoveMethod As Long) As Long
Public Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long

Codigo:
dim HandlerFile as long
dim sa as SECURITY_ATTRIBUTES
handlerfile=createfile("c:\pepe.txt", FILE_APPEND_DATA,0,sa,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,0)
if handlerfile<>INVALID_HANDLE_VALUE then
setfilepointer(handlerfile,0,0,FILE_END)
'Aqui con la llamada a la api writefile funciona correctamente
end if
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar