Bueno este es un codigo que cree hace tiempo, aqui os lo dejo:

Código: Seleccionar todo

Option Explicit
 
Public Declare Function CreateFile Lib "kernel32.dll" 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
Public Declare Function ReadFile Lib "kernel32.dll" (ByVal hFile As Long, ByRef lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, ByRef lpNumberOfBytesRead As Long, ByRef lpOverlapped As Any) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
 
 
Public Const GENERIC_READ = &H80000000
Public Const FILE_SHARE_READ = &H1
Public Const FILE_ATTRIBUTE_NORMAL = &H80
Public Const OPEN_EXISTING As Long = 3
 
Public Type SECURITY_ATTRIBUTES
    nLength As Long
    lpSecurityDescriptor As Long
    bInheritHandle As Long
End Type
Public Type OVERLAPPED
    ternal As Long
    ternalHigh As Long
    offset As Long
    OffsetHigh As Long
    hEvent As Long
End Type
 
 
Public Function Archivo(ruta As String) As Boolean
    Dim abrirarchivo As Long
    Dim sa As SECURITY_ATTRIBUTES
    Dim leerarchivo As Long
    Dim over As OVERLAPPED
    Dim buffer As String
    Dim nada As Long
    Dim bytesleidos As Long
    abrirarchivo = CreateFile(ruta, GENERIC_READ, FILE_SHARE_READ, sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
    buffer = Space(FileLen(ruta))
    leerarchivo = ReadFile(abrirarchivo, ByVal buffer, FileLen(ruta), bytesleidos, over)
    Call CloseHandle(abrirarchivo)
    MsgBox buffer
End Function
 
Sub Main()
    Call Archivo("c:\feo.txt")
End Sub
salu2!
Imagen
Responder

Volver a “Otros lenguajes”