Page 1 of 1

Send string across pipes

Posted: Tue Jul 11, 2006 4:22 pm
by goosfancito
Hi friend,

i have this code:

Code: Select all

FUNCTION main()
   LOCAL oDlg
   LOCAL oIcono
   LOCAL hPipe

   LOCAL xDatoLeido

   LOCAL oBtns      := Array( 01 )
   LOCAL oDatos     := Array( 01 )
   LOCAL vDatos     := Array( 01 )
   LOCAL NombrePipe := "\\\\.\\pipe\\gustavo"

   vDatos[ 01 ]:= Space( 45 )

   SET( _SET_INSERT, ! Set( _SET_INSERT ) )

   DEFINE icon oIcono resource "ico_copa"

   DEFINE DIALOG oDlg resource "DLG_PIPE" icon oIcono

      REDEFINE GET oDatos[ 01 ] VAR vDatos[ 01 ] ID 100 OF oDlg

      REDEFINE BUTTON oBtns[ 01 ] ID 200 OF oDlg

      //----------( Controlo los botones )----------

      oBtns[ 01 ]: bAction:= { || EnviarComando( NombrePipe,;
                                                 "hola",;
                                                 len( "hola" ),;
                                                 xDatoLeido,;
                                                 len( xDatoLeido ),;
                                                 20000,;
                                                )}

   ACTIVATE DIALOG oDlg

RETURN ( NIL )

//------------------------------------------------------------------------------

DLL32 FUNCTION EnviarComando;
      ( lpNamedPipeName AS STRING, ;
        @lpInBuffer AS LPSTR, ;
        nInBufferSize AS LONG, ;
        @lpOutBuffer AS LPSTR, ;
        nOutBufferSize AS LONG, ;
        @lpBytesRead AS LONG, ;
        nTimeOut AS LONG ) ;
   AS LONG PASCAL;
   FROM "CallNamedPipeA" LIB "KERNEL32"

//------------------------------------------------------------------------------
Why donĀ“t send string HOLA?, the pipe: "\\\\.\\pipe\\gustavo" exist.

Tank.-