473,788 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.

Jul 3 '08 #1
7 7653
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
Jul 3 '08 #2
On 2008-07-03, andrewb <aj*****@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
Jul 3 '08 #3
On 2008-07-03, Tom Shelton <to*********@co mcastXXXXXXX.ne twrote:
On 2008-07-03, andrewb <aj*****@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
Jul 3 '08 #4
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
Jul 3 '08 #5
"andrewb" <aj*****@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/>

Jul 3 '08 #6
On 2008-07-03, andrewb <aj*****@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
Jul 3 '08 #7
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
Jul 4 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5292
by: Matt W | last post by:
Hi all, I just noticed this in the manual yesterday: http://www.mysql.com/doc/en/Windows_running.html "MySQL supports TCP/IP on all Windows platforms. The mysqld-nt and mysql-max-nt servers support named pipes on NT, 2000, and XP. The default is to use TCP/IP regardless of the platform, because named pipes are actually *slower* than TCP/IP ..."
5
18145
by: glenn.owens | last post by:
In the process of doing some routine monitoring/clean-up we've discovered that several (many?) users are apparently set to access our SQL Server 2000 database instances via the Named Pipes protocol. In readings and recommendations we've decided that our WAN would be best served if we use the less "chatty" TCP/IP. As such we've also decided to try to enforce this decision to use TCP/IP exclusively using the domain login script used by all...
2
2715
by: Rudolf Bargholz | last post by:
Hi, DB2 7.1 FP11 Windows 2000 Earlier this evening, after dropping and recreating a trigger, DB2 locked up. I am not entirely sure that the cause of the problem was the replacing of the trigger, but all of a sudden no users were able to connect to our customers database. After running db2dart I found numerous corrupted indexes which I removed using "db2dart MYDB /IM". Finally I was able to get a
4
7661
by: Ken Allen | last post by:
Is there any built-in facility for handling named pipes in C#/.Net, or must one use unsafe code to access the WIN32 API directly? There exists some code that uses named pipes heavily and there exists a need for that code to send some information to a new .Net service I am writing. It is a relatively simple matter for the existing code to use a named pipe to send the data, but I can find no references to how I can create the named pipe...
2
2030
by: Belee | last post by:
1. I am using sql server express and visual studio 2003. I have been able to create the connection to the database in server explorer but cannot update table definitions. It gives an error that I may need a patch or changes would not be saved. So I have to do the table changes in SQL Express Management studio. 2. When I modify a stored procedure in the management studio of sql express, it does not update but rather saves it the...
5
3813
by: Microsoft | last post by:
Hi, I have Visual Basic .net 2003 (Standard Edition) & SQL Server 2000 Developer Edition. When trying to create a connection in the server explorer from the .net IDE I get a number of problems; a.. Under the "Connection" tab, under "1. Select or enter a server name:" when I either select the drop down box or click the refresh button I get an error dialog saying "Error enumerating data servers. Enumerator reports Unspecified error'". The...
1
1681
by: Jarrod Morrison | last post by:
Hi All Im looking for a way use named pipes between a service app and an app run when a user logs on and be able to pass string based data, im hoping that the service can contact the app that is running in the user session and tell it a path of an app to launch as the logged on user. Does anybody know of an easy way to do this or have any examples i could look at ? Any help is greatly appreciated Many thanks
2
2546
by: fahad.usman | last post by:
I am making an application in which if the second instance of the same application is launched, it checks its command-line arguments and passes them to the already running instance. I have been told by someone that using named pipes is one of the most commonly used ways of doing this. But I did it in a simpler way; I saved the command-line arguments in a text file and passed a message to the previously running instance to read the...
1
5565
by: dgk | last post by:
I trying to use a named pipe but can't figure out how to get the callback to work: Module Module1 Private ps As System.IO.Pipes.NamedPipeServerStream Public Sub main() Application.EnableVisualStyles() Try ps = New System.IO.Pipes.NamedPipeServerStream("Test") ps.BeginWaitForConnection(AddressOf HandleConnection, "Test")
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.