Visual Basic .NET & named pipes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • andrewb

    #1

    Visual Basic .NET & named pipes

    Hi all,

    Having some trouble using named pipes and Visual Basic .NET and would
    appreciate and help you could offer.

    Essentially I am trying to develop a simple client/server application
    that exchanges text messages using named pipes. The internet resources
    seem a bit scarce and the only Microsoft resource I can find is
    http://support.microsoft.com/kb/871044.

    I have managed to get the above KB example working but I am struggling
    to convert it to just use string data between the client & server.

    Anyone done this already using Visual Basic .NET?

    Cheers.

  • kimiraikkonen

    #2
    Re: Visual Basic .NET & named pipes

    On Jul 3, 1:39 pm, andrewb <ajba...@deloit te.co.ukwrote:
    Hi all,
    >
    Having some trouble using named pipes and Visual Basic .NET and would
    appreciate and help you could offer.
    >
    Essentially I am trying to develop a simple client/server application
    that exchanges text messages using named pipes. The internet resources
    seem a bit scarce and the only Microsoft resource I can find ishttp://support.microso ft.com/kb/871044.
    >
    I have managed to get the above KB example working but I am struggling
    to convert it to just use string data between the client & server.
    >
    Anyone done this already using Visual Basic .NET?
    >
    Cheers.
    Hi,
    I hope that provides better info for sending strings using pipes:
    http://msdn.microsoft.com/en-us/libr...verstream.aspx

    or:

    http://msdn.microsoft.com/en-us/libr....io.pipes.aspx

    However you can also consider using System.Net.Sock ets.

    HTH,

    Onur Güzel

    Comment

    • Tom Shelton

      #3
      Re: Visual Basic .NET &amp; named pipes

      On 2008-07-03, andrewb <ajbaker@deloit te.co.ukwrote:
      Hi all,
      >
      Having some trouble using named pipes and Visual Basic .NET and would
      appreciate and help you could offer.
      >
      Essentially I am trying to develop a simple client/server application
      that exchanges text messages using named pipes. The internet resources
      seem a bit scarce and the only Microsoft resource I can find is
      http://support.microsoft.com/kb/871044.
      >
      I have managed to get the above KB example working but I am struggling
      to convert it to just use string data between the client & server.
      >
      Anyone done this already using Visual Basic .NET?
      >
      Cheers.
      >
      What version of VB are you using? If your using 2008, then you might want to
      take a look at System.IO.Pipes - they are now part of the framework. You can
      find documentation and examples here:

      http://msdn.microsoft.com/en-us/libr....io.pipes.aspx

      If you must use the API example... Then the simple answer is to convert your
      strings to byte arrays before sending them accross the pipe:

      ' send data
      Dim dataBuffer() As Byte = Encoding.Defaul t.GetBytes(stri ngData)
      WriteFile(..... .)


      ' receive data
      ReadFile(...dat aBuffer...)
      ....
      Dim stringData As String = Encoding.Defaul t.GetString(dat aBuffer)

      --
      Tom Shelton

      Comment

      • Tom Shelton

        #4
        Re: Visual Basic .NET &amp; named pipes

        On 2008-07-03, Tom Shelton <tom_shelton@co mcastXXXXXXX.ne twrote:
        On 2008-07-03, andrewb <ajbaker@deloit te.co.ukwrote:
        >Hi all,
        >>
        >Having some trouble using named pipes and Visual Basic .NET and would
        >appreciate and help you could offer.
        >>
        >Essentially I am trying to develop a simple client/server application
        >that exchanges text messages using named pipes. The internet resources
        >seem a bit scarce and the only Microsoft resource I can find is
        >http://support.microsoft.com/kb/871044.
        >>
        >I have managed to get the above KB example working but I am struggling
        >to convert it to just use string data between the client & server.
        >>
        >Anyone done this already using Visual Basic .NET?
        >>
        >Cheers.
        >>
        >
        What version of VB are you using? If your using 2008, then you might want to
        take a look at System.IO.Pipes - they are now part of the framework. You can
        find documentation and examples here:
        >
        http://msdn.microsoft.com/en-us/libr....io.pipes.aspx
        >
        If you must use the API example... Then the simple answer is to convert your
        strings to byte arrays before sending them accross the pipe:
        >
        ' send data
        Dim dataBuffer() As Byte = Encoding.Defaul t.GetBytes(stri ngData)
        WriteFile(..... .)
        >
        >
        ' receive data
        ReadFile(...dat aBuffer...)
        ...
        Dim stringData As String = Encoding.Defaul t.GetString(dat aBuffer)
        >
        I should probably mention... If all of your strings can be represented in
        ASCII then, you can actually use Encoding.ASCII on both ends.

        --
        Tom Shelton

        Comment

        • andrewb

          #5
          Re: Visual Basic .NET &amp; named pipes

          Thanks for the help guys - appreciate it

          I am using Visual Studio 2005, still unable to get a string through -
          here is my code, hopefully you can spot my error(s) :

          Server code
          =========

          Dim pipeName As String = "\\.\pipe\MServ erPipe"
          Dim hPipe As Integer
          Dim openMode, pipeMode As Integer

          Dim stringIn As String
          Dim dataIn(256) As Byte

          Dim res, nChars As Integer

          openMode = PIPE_ACCESS_DUP LEX Or FILE_FLAG_WRITE _THROUGH
          pipeMode = PIPE_WAIT Or PIPE_TYPE_MESSA GE Or
          PIPE_READMODE_M ESSAGE

          hPipe = CreateNamedPipe (pipeName, openMode, pipeMode, 10,
          10000, 2000, 10000, IntPtr.Zero)

          res = ConnectNamedPip e(hPipe, 0)

          res = ReadFile(hPipe, dataIn, 256, nChars, 0)
          stringIn = System.Text.Enc oding.ASCII.Get String(dataIn)

          CloseHandle(hPi pe)

          Client code
          ========

          Dim pipeName As String = "\\.\pipe\MServ erPipe"

          Dim res, cbRead, numBytes As Integer
          Dim stringOut As String
          Dim dataOut(256), dataIn(256) As Byte

          stringOut = "This is a test"
          dataOut = System.Text.Enc oding.ASCII.Get Bytes(stringOut )

          res = CallNamedPipe(p ipeName, dataOut, stringOut.Lengt h,
          dataIn, numBytes, cbRead, 30000)

          API declarations
          ============

          Public Declare Function CallNamedPipe Lib "kernel32" Alias
          "CallNamedPipeA " _
          (ByVal lpNamedPipeName As String, _
          ByRef lpInBuffer() As Byte, _
          ByVal nInBufferSize As Integer, _
          ByRef lpOutBuffer() As Byte, _
          ByVal nOutBufferSize As Integer, _
          ByRef lpBytesRead As Integer, ByVal nTimeOut As Integer) As
          Integer

          Declare Function WriteFile Lib "kernel32" _
          (ByVal hFile As Integer, ByRef lpBuffer() As Byte, _
          ByVal nNumberOfBytesT oWrite As Integer, ByRef
          lpNumberOfBytes Written As Integer, _
          ByVal lpOverlapped As Integer _
          ) As Integer

          Declare Function ReadFile Lib "kernel32" _
          (ByVal hFile As Integer, ByVal lpBuffer() As Byte, _
          ByVal nNumberOfBytesT oRead As Integer, ByRef
          lpNumberOfBytes Read As Integer, _
          ByVal lpOverlapped As Integer _
          ) As Integer

          Comment

          • Herfried K. Wagner [MVP]

            #6
            Re: Visual Basic .NET &amp; named pipes

            "andrewb" <ajbaker@deloit te.co.ukschrieb :
            Dim pipeName As String = "\\.\pipe\MServ erPipe"
            >
            Dim res, cbRead, numBytes As Integer
            Dim stringOut As String
            Dim dataOut(256), dataIn(256) As Byte
            Note that these arrays will have 257 elements with indices running from 0 to
            256.
            Public Declare Function CallNamedPipe Lib "kernel32" Alias
            "CallNamedPipeA " _
            Is there any reason you are using the Windows ANSI version of the function?
            If not, use 'Public Declare Auto Function' and remove the alias.

            ByRef lpBytesRead As Integer, ByVal nTimeOut As Integer) As
            Integer
            ='As Boolean'.
            Declare Function WriteFile Lib "kernel32" _
            (ByVal hFile As Integer
            ='ByVal hFile As IntPtr'.

            , ByRef lpBuffer() As Byte, _
            ByVal nNumberOfBytesT oWrite As Integer, ByRef
            lpNumberOfBytes Written As Integer, _
            ByVal lpOverlapped As Integer _
            ='As IntPtr'.
            ) As Integer
            ='As Boolean'.

            The same applies to 'ReadFile'.

            --
            M S Herfried K. Wagner
            M V P <URL:http://dotnet.mvps.org/>
            V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

            Comment

            • Tom Shelton

              #7
              Re: Visual Basic .NET &amp; named pipes

              On 2008-07-03, andrewb <ajbaker@deloit te.co.ukwrote:
              Thanks for the help guys - appreciate it
              >
              I am using Visual Studio 2005, still unable to get a string through -
              here is my code, hopefully you can spot my error(s) :
              >
              Server code
              >=========
              >
              Dim pipeName As String = "\\.\pipe\MServ erPipe"
              Dim hPipe As Integer
              Dim openMode, pipeMode As Integer
              >
              Dim stringIn As String
              Dim dataIn(256) As Byte
              >
              Dim res, nChars As Integer
              >
              openMode = PIPE_ACCESS_DUP LEX Or FILE_FLAG_WRITE _THROUGH
              pipeMode = PIPE_WAIT Or PIPE_TYPE_MESSA GE Or
              PIPE_READMODE_M ESSAGE
              >
              hPipe = CreateNamedPipe (pipeName, openMode, pipeMode, 10,
              10000, 2000, 10000, IntPtr.Zero)
              >
              res = ConnectNamedPip e(hPipe, 0)
              >
              res = ReadFile(hPipe, dataIn, 256, nChars, 0)
              stringIn = System.Text.Enc oding.ASCII.Get String(dataIn)
              >
              CloseHandle(hPi pe)
              >
              Client code
              >========
              >
              Dim pipeName As String = "\\.\pipe\MServ erPipe"
              >
              Dim res, cbRead, numBytes As Integer
              Dim stringOut As String
              Dim dataOut(256), dataIn(256) As Byte
              >
              stringOut = "This is a test"
              dataOut = System.Text.Enc oding.ASCII.Get Bytes(stringOut )
              >
              res = CallNamedPipe(p ipeName, dataOut, stringOut.Lengt h,
              dataIn, numBytes, cbRead, 30000)
              >
              API declarations
              >============
              >
              Public Declare Function CallNamedPipe Lib "kernel32" Alias
              "CallNamedPipeA " _
              (ByVal lpNamedPipeName As String, _
              ByRef lpInBuffer() As Byte, _
              ByVal nInBufferSize As Integer, _
              ByRef lpOutBuffer() As Byte, _
              ByVal nOutBufferSize As Integer, _
              ByRef lpBytesRead As Integer, ByVal nTimeOut As Integer) As
              Integer
              >
              Declare Function WriteFile Lib "kernel32" _
              (ByVal hFile As Integer, ByRef lpBuffer() As Byte, _
              ByVal nNumberOfBytesT oWrite As Integer, ByRef
              lpNumberOfBytes Written As Integer, _
              ByVal lpOverlapped As Integer _
              ) As Integer
              >
              Declare Function ReadFile Lib "kernel32" _
              (ByVal hFile As Integer, ByVal lpBuffer() As Byte, _
              ByVal nNumberOfBytesT oRead As Integer, ByRef
              lpNumberOfBytes Read As Integer, _
              ByVal lpOverlapped As Integer _
              ) As Integer

              Ok... I looked at their sample, and here is what I have:

              ' client
              Option Strict On
              Option Explicit On

              Imports System.Text

              Module Module1

              Sub Main()


              Dim outBuffer() As Byte = Encoding.ASCII. GetBytes("Hi, Server!")
              Dim inBuffer(BUFFSI ZE) As Byte
              Dim bytesRead As Integer

              'Call the CallNamedPipe function to do the transactions
              CallNamedPipe(p ipeName, outBuffer, outBuffer.Lengt h, inBuffer, inBuffer.Length , bytesRead, 30000)
              Console.WriteLi ne(Encoding.ASC II.GetString(in Buffer, 0, bytesRead))
              End Sub

              Private Const pipeName As String = "\\.\pipe\MyPip e"
              Private Const BUFFSIZE As Integer = 10000
              Private hpipe As IntPtr

              Public ReadOnly INVALID_HANDLE_ VALUE As IntPtr = New IntPtr(-1)

              Public Declare Auto Function CallNamedPipe Lib "kernel32" ( _
              ByVal lpNamedPipeName As String, _
              ByVal lpInBuffer() As Byte, _
              ByVal nInBufferSize As Integer, _
              ByVal lpOutBuffer() As Byte, _
              ByVal nOutBufferSize As Integer, _
              ByRef lpBytesRead As Integer, _
              ByVal nTimeOut As Integer) As Boolean

              End Module

              ' server
              Option Strict On
              Option Explicit On

              Imports System.Text

              Module Module1
              Private Const pipeName As String = "\\.\pipe\MyPip e"
              Private Const BUFFSIZE As Short = 10000
              Private hPipe As IntPtr

              Sub Main()
              Dim openMode As Integer
              Dim pipeMode As Integer

              'Create the named pipe
              openMode = PIPE_ACCESS_DUP LEX Or FILE_FLAG_WRITE _THROUGH
              pipeMode = PIPE_WAIT Or PIPE_TYPE_MESSA GE Or PIPE_READMODE_M ESSAGE

              hPipe = CreateNamedPipe (pipeName, openMode, pipeMode, 10, 10000, 2000, 10000, IntPtr.Zero)
              If hPipe <INVALID_HANDLE _VALUE Then
              Console.WriteLi ne("Created the named pipe and waiting for the clients.")

              Dim byteCount As Integer
              Dim i As Integer
              Dim cbnCount As Integer

              Dim outBuffer() As Byte = Encoding.ASCII. GetBytes("Hello from the server")
              Dim inputBuffer(BUF FSIZE) As Byte

              'Wait for a connection, block until a client connects
              Console.WriteLi ne("Waiting for client connections")

              Do
              ConnectNamedPip e(hPipe, IntPtr.Zero)

              ''Read the data sent by the client over the pipe
              cbnCount = BUFFSIZE
              ReadFile(hPipe, inputBuffer, inputBuffer.Len gth, cbnCount, IntPtr.Zero)
              Console.WriteLi ne("Client Says {0}", Encoding.ASCII. GetString(input Buffer, 0, cbnCount))


              WriteFile(hPipe , outBuffer, outBuffer.Lengt h, cbnCount, IntPtr.Zero)
              'res = FlushFileBuffer s(hPipe)
              ''Disconnect the named pipe.
              DisconnectNamed Pipe(hPipe)
              'Loop until the client makes no more requests for data.
              Loop Until byteCount = 0

              Console.WriteLi ne("Read or Write completed")

              'Close the pipe handle when the client makes no requests
              CloseHandle(hPi pe)
              Console.WriteLi ne("Disconnecte d the named pipe")
              Else
              Console.WriteLi ne("Pipe creation failed")
              End If
              End Sub

              Public Const FILE_ATTRIBUTE_ NORMAL As Short = &H80S
              Public Const FILE_FLAG_NO_BU FFERING As Integer = &H20000000
              Public Const FILE_FLAG_WRITE _THROUGH As Integer = &H80000000

              Public Const PIPE_ACCESS_DUP LEX As Short = &H3S
              Public Const PIPE_READMODE_M ESSAGE As Short = &H2S
              Public Const PIPE_TYPE_MESSA GE As Short = &H4S
              Public Const PIPE_WAIT As Short = &H0S

              Public ReadOnly INVALID_HANDLE_ VALUE As IntPtr = New IntPtr(-1)

              Declare Auto Function CreateNamedPipe Lib "kernel32" ( _
              ByVal lpName As String, _
              ByVal dwOpenMode As Integer, _
              ByVal dwPipeMode As Integer, _
              ByVal nMaxInstances As Integer, _
              ByVal nOutBufferSize As Integer, _
              ByVal nInBufferSize As Integer, _
              ByVal nDefaultTimeOut As Integer, _
              ByVal lpSecurityAttri butes As IntPtr _
              ) As IntPtr

              Declare Function ConnectNamedPip e Lib "kernel32" ( _
              ByVal hNamedPipe As IntPtr, _
              ByVal lpOverlapped As IntPtr _
              ) As Boolean

              Declare Function DisconnectNamed Pipe Lib "kernel32" ( _
              ByVal hNamedPipe As IntPtr _
              ) As Boolean

              Declare Function WriteFile Lib "kernel32" ( _
              ByVal hFile As IntPtr, _
              ByVal lpBuffer() As Byte, _
              ByVal nNumberOfBytesT oWrite As Integer, _
              ByRef lpNumberOfBytes Written As Integer, _
              ByVal lpOverlapped As IntPtr _
              ) As Integer

              Declare Function ReadFile Lib "kernel32" ( _
              ByVal hFile As IntPtr, _
              ByVal lpBuffer() As Byte, _
              ByVal nNumberOfBytesT oRead As Integer, _
              ByRef lpNumberOfBytes Read As Integer, _
              ByVal lpOverlapped As IntPtr _
              ) As Integer

              Declare Function FlushFileBuffer s Lib "kernel32" _
              (ByVal hFile As IntPtr) As Integer

              Declare Function CloseHandle Lib "kernel32" _
              (ByVal hObject As IntPtr) As Integer

              End Module

              They made a lot of strange choices for their declares :) Anyway - hope this
              helps.

              --
              Tom Shelton

              Comment

              • andrewb

                #8
                Re: Visual Basic .NET &amp; named pipes

                On 4 Jul, 00:14, Tom Shelton <tom_shel...@co mcastXXXXXXX.ne twrote:
                On 2008-07-03, andrewb <ajba...@deloit te.co.ukwrote:
                >
                >
                >
                >
                >
                Thanks for the help guys - appreciate it
                >
                I am using Visual Studio 2005, still unable to get a string through -
                here is my code, hopefully you can spot my error(s) :
                >
                Server code
                =========
                >
                        Dim pipeName As String = "\\.\pipe\MServ erPipe"
                        Dim hPipe As Integer
                        Dim openMode, pipeMode As Integer
                >
                        Dim stringIn As String
                        Dim dataIn(256) As Byte
                >
                        Dim res, nChars As Integer
                >
                        openMode = PIPE_ACCESS_DUP LEX Or FILE_FLAG_WRITE _THROUGH
                        pipeMode = PIPE_WAIT Or PIPE_TYPE_MESSA GE Or
                PIPE_READMODE_M ESSAGE
                >
                        hPipe = CreateNamedPipe (pipeName, openMode, pipeMode,10,
                10000, 2000, 10000, IntPtr.Zero)
                >
                        res = ConnectNamedPip e(hPipe, 0)
                >
                        res = ReadFile(hPipe, dataIn, 256, nChars, 0)
                        stringIn = System.Text.Enc oding.ASCII.Get String(dataIn)
                >
                        CloseHandle(hPi pe)
                >
                Client code
                ========
                >
                        Dim pipeName As String = "\\.\pipe\MServ erPipe"
                >
                        Dim res, cbRead, numBytes As Integer
                        Dim stringOut As String
                        Dim dataOut(256), dataIn(256) As Byte
                >
                        stringOut = "This is a test"
                        dataOut = System.Text.Enc oding.ASCII.Get Bytes(stringOut )
                >
                        res = CallNamedPipe(p ipeName, dataOut, stringOut.Lengt h,
                dataIn, numBytes, cbRead, 30000)
                >
                API declarations
                ============
                >
                    Public Declare Function CallNamedPipe Lib "kernel32" Alias
                "CallNamedPipeA " _
                        (ByVal lpNamedPipeName As String, _
                        ByRef lpInBuffer() As Byte, _
                        ByVal nInBufferSize As Integer, _
                        ByRef lpOutBuffer() As Byte, _
                        ByVal nOutBufferSize As Integer, _
                        ByRef lpBytesRead As Integer, ByVal nTimeOut As Integer) As
                Integer
                >
                    Declare Function WriteFile Lib "kernel32" _
                    (ByVal hFile As Integer, ByRef lpBuffer() As Byte, _
                    ByVal nNumberOfBytesT oWrite As Integer, ByRef
                lpNumberOfBytes Written As Integer, _
                    ByVal lpOverlapped As Integer _
                    ) As Integer
                >
                    Declare Function ReadFile Lib "kernel32" _
                        (ByVal hFile As Integer, ByVal lpBuffer() As Byte, _
                            ByVal nNumberOfBytesT oRead As Integer, ByRef
                lpNumberOfBytes Read As Integer, _
                            ByVal lpOverlapped As Integer _
                        ) As Integer
                >
                Ok... I looked at their sample, and here is what I have:
                >
                ' client
                Option Strict On
                Option Explicit On
                >
                Imports System.Text
                >
                Module Module1
                >
                    Sub Main()
                >
                        Dim outBuffer() As Byte = Encoding.ASCII. GetBytes("Hi, Server!")
                        Dim inBuffer(BUFFSI ZE) As Byte
                        Dim bytesRead As Integer
                >
                        'Call the CallNamedPipe function to do the transactions
                        CallNamedPipe(p ipeName, outBuffer, outBuffer.Lengt h, inBuffer, inBuffer.Length , bytesRead, 30000)
                        Console.WriteLi ne(Encoding.ASC II.GetString(in Buffer, 0, bytesRead))
                    End Sub
                >
                    Private Const pipeName As String = "\\.\pipe\MyPip e"
                    Private Const BUFFSIZE As Integer = 10000
                    Private hpipe As IntPtr
                >
                    Public ReadOnly INVALID_HANDLE_ VALUE As IntPtr = New IntPtr(-1)
                >
                    Public Declare Auto Function CallNamedPipe Lib "kernel32" ( _
                        ByVal lpNamedPipeName As String, _
                        ByVal lpInBuffer() As Byte, _
                        ByVal nInBufferSize As Integer, _
                        ByVal lpOutBuffer() As Byte, _
                        ByVal nOutBufferSize As Integer, _
                        ByRef lpBytesRead As Integer, _
                        ByVal nTimeOut As Integer) As Boolean
                >
                End Module
                >
                ' server
                Option Strict On
                Option Explicit On
                >
                Imports System.Text
                >
                Module Module1
                    Private Const pipeName As String = "\\.\pipe\MyPip e"
                    Private Const BUFFSIZE As Short = 10000
                    Private hPipe As IntPtr
                >
                    Sub Main()
                        Dim openMode As Integer
                        Dim pipeMode As Integer
                >
                        'Create the named pipe
                        openMode = PIPE_ACCESS_DUP LEX Or FILE_FLAG_WRITE _THROUGH
                        pipeMode = PIPE_WAIT Or PIPE_TYPE_MESSA GE Or PIPE_READMODE_M ESSAGE
                >
                        hPipe = CreateNamedPipe (pipeName, openMode, pipeMode, 10, 10000, 2000, 10000, IntPtr.Zero)
                        If hPipe <INVALID_HANDLE _VALUE Then
                            Console.WriteLi ne("Created the named pipe and waiting for the clients.")
                >
                            Dim byteCount As Integer
                            Dim i As Integer
                            Dim cbnCount As Integer
                >
                            Dim outBuffer() As Byte = Encoding.ASCII. GetBytes("Hello from the server")
                            Dim inputBuffer(BUF FSIZE) As Byte
                >
                            'Wait for a connection, block until a client connects
                            Console.WriteLi ne("Waiting for client connections")
                >
                            Do
                                ConnectNamedPip e(hPipe, IntPtr.Zero)
                >
                                ''Read the data sent by the client over the pipe
                                cbnCount = BUFFSIZE
                                ReadFile(hPipe, inputBuffer, inputBuffer.Len gth, cbnCount, IntPtr.Zero)
                                Console.WriteLi ne("Client Says {0}", Encoding.ASCII. GetString(input Buffer, 0, cbnCount))
                >
                                WriteFile(hPipe , outBuffer, outBuffer.Lengt h, cbnCount, IntPtr.Zero)
                                'res = FlushFileBuffer s(hPipe)
                                ''Disconnect the named pipe.
                                DisconnectNamed Pipe(hPipe)
                                'Loop until the client makes no more requests for data.
                            Loop Until byteCount = 0
                >
                            Console.WriteLi ne("Read or Write completed")
                >
                            'Close the pipe handle when the client makes no requests
                            CloseHandle(hPi pe)
                            Console.WriteLi ne("Disconnecte d the named pipe")
                        Else
                            Console.WriteLi ne("Pipe creation failed")
                        End If
                    End Sub
                >
                    Public Const FILE_ATTRIBUTE_ NORMAL As Short = &H80S
                    Public Const FILE_FLAG_NO_BU FFERING As Integer = &H20000000
                    Public Const FILE_FLAG_WRITE _THROUGH As Integer = &H80000000
                >
                    Public Const PIPE_ACCESS_DUP LEX As Short = &H3S
                    Public Const PIPE_READMODE_M ESSAGE As Short = &H2S
                    Public Const PIPE_TYPE_MESSA GE As Short = &H4S
                    Public Const PIPE_WAIT As Short = &H0S
                >
                    Public ReadOnly INVALID_HANDLE_ VALUE As IntPtr = New IntPtr(-1)
                >
                    Declare Auto Function CreateNamedPipe Lib "kernel32" ( _
                        ByVal lpName As String, _
                        ByVal dwOpenMode As Integer, _
                        ByVal dwPipeMode As Integer, _
                        ByVal nMaxInstances As Integer, _
                        ByVal nOutBufferSize As Integer, _
                        ByVal nInBufferSize As Integer, _
                        ByVal nDefaultTimeOut As Integer, _
                        ByVal lpSecurityAttri butes As IntPtr _
                    ) As IntPtr
                >
                    Declare Function ConnectNamedPip e Lib "kernel32" ( _
                        ByVal hNamedPipe As IntPtr, _
                        ByVal lpOverlapped As IntPtr _
                    ) As Boolean
                >
                    Declare Function DisconnectNamed Pipe Lib "kernel32" ( _
                        ByVal hNamedPipe As IntPtr _
                    ) As Boolean
                >
                    Declare Function WriteFile Lib "kernel32" ( _
                        ByVal hFile As IntPtr, _
                        ByVal lpBuffer() As Byte, _
                        ByVal nNumberOfBytesT oWrite As Integer, _
                        ByRef lpNumberOfBytes Written As Integer, _
                        ByVal lpOverlapped As IntPtr _
                    ) As Integer
                >
                    Declare Function ReadFile Lib "kernel32" ( _
                        ByVal hFile As IntPtr, _
                        ByVal lpBuffer() As Byte, _
                        ByVal nNumberOfBytesT oRead As Integer, _
                        ByRef lpNumberOfBytes Read As Integer, _
                        ByVal lpOverlapped As IntPtr _
                    ) As Integer
                >
                    Declare Function FlushFileBuffer s Lib "kernel32" _
                        (ByVal hFile As IntPtr) As Integer
                >
                    Declare Function CloseHandle Lib "kernel32" _
                        (ByVal hObject As IntPtr) As Integer
                >
                End Module
                >
                They made a lot of strange choices for their declares :) Anyway - hope this
                helps.
                >
                --
                Tom Shelton- Hide quoted text -
                >
                - Show quoted text -
                Awesome - job done - thanks Tom

                Comment

                Working...