FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour DLL32 FUNCTION ReadFile;
Posts: 1956
Joined: Fri Oct 07, 2005 07:08 PM
DLL32 FUNCTION ReadFile;
Posted: Tue Jul 11, 2006 12:19 PM

Amigos,

Alguien tiene un ejemplo de como utilizar desde FWH la funcion:

DLL32 FUNCTION ReadFile;
( hFile AS LONG, ;
@lpBuffer AS LPSTR, ;
nNumberOfBytesToRead AS LONG, ;
@lpNumberOfBytesRead AS LONG, ;
@lpOverlapped AS LPSTR ) ; // OVERLAPPED
AS LONG PASCAL;
LIB "KERNEL32"

Gracias.

Especificamente necesito enviar una cadena por un handle.

FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
Posts: 458
Joined: Tue Mar 14, 2006 07:26 PM
DLL32 FUNCTION ReadFile;
Posted: Tue Jul 11, 2006 05:50 PM

Hola,

No te entiendo muy bien, pero si quieres leer o escribir desde / a un fichero, existen las funciones de bajo nivel, fopen(), fread(), fread(), fclose(), etc. Y todas usan un handle devuelto por fopen() o fcreate()

Un Saludo,
Joaquín

Un Saludo,

Joaquín Martínez
Posts: 1956
Joined: Fri Oct 07, 2005 07:08 PM
DLL32 FUNCTION ReadFile;
Posted: Tue Jul 11, 2006 06:05 PM
hola,

Estoy tratando de enviar cadenas a traves de tuberias ( pipes ) con el comando CallNamedPipe, y una vez que se establece la comunicacion hay que utilizar

DLL32 FUNCTION ReadFile;
( hFile AS LONG, ;
@lpBuffer AS LPSTR, ;
nNumberOfBytesToRead AS LONG, ;
@lpNumberOfBytesRead AS LONG, ;
@lpOverlapped AS LPSTR ) ; // OVERLAPPED
AS LONG PASCAL;
LIB "KERNEL32"


Pero aparecen datos como: LPSTR, LONG y no se como traducirlos a FWH.
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
Posts: 458
Joined: Tue Mar 14, 2006 07:26 PM
DLL32 FUNCTION ReadFile;
Posted: Tue Jul 11, 2006 06:31 PM

Sería algo como,

hFile := fOpen() ó fCreate()
lpBuffer:= Space(255)
nNumberOfBytesToRead := 254
lpNumberOfBytesRead := 0
lpOverlapped := Space(255)

ReadFile( hFile , @lpBuffer, nNumberOfBytesToRead, @lpNumberOfBytesRead, @lpOverlapped )

lpNumberOfBytesRead -> Nº de Bytes que ha leído si <> de nNumberOfBytesToRead fin del fichero a leer

Un Saludo,
Joaquín

Un Saludo,

Joaquín Martínez
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
DLL32 FUNCTION ReadFile;
Posted: Tue Jul 11, 2006 08:53 PM

Gustavo,

Los parámetros LPSTR no hay que pasarlos, ni declararlos, por referencia. Ya que un LPSTR por definición es un puntero (la dirección) a una cadena.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1956
Joined: Fri Oct 07, 2005 07:08 PM
DLL32 FUNCTION ReadFile;
Posted: Tue Jul 11, 2006 08:58 PM
Antonio,

Entonces tomando el ejmplo del amigo quedaría asi?:

hFile := // Acá crearia un handle, que en mi caso es create...

lpBuffer:= Space(255) 
nNumberOfBytesToRead := 254 
lpNumberOfBytesRead := 0 
lpOverlapped := Space(255) 


ReadFile( hFile ,
              lpBuffer, ;
              nNumberOfBytesToRead, ;
              lpNumberOfBytesRead, ;
              lpOverlapped )

Es correcto?
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
DLL32 FUNCTION ReadFile;
Posted: Tue Jul 11, 2006 10:26 PM

Gustavo,

lpNumberOfBytesRead tienes que definirlo y pasarlo por referencia porque es un puntero a un long (la dirección en donde está un número long). Lo demás parece estar bien.

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion