472,374 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,374 software developers and data experts.

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 7433
On Jul 3, 1:39*pm, andrewb <ajba...@deloitte.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.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.
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.Sockets.

HTH,

Onur Güzel
Jul 3 '08 #2
On 2008-07-03, andrewb <aj*****@deloitte.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.Default.GetBytes(stringData)
WriteFile(......)
' receive data
ReadFile(...dataBuffer...)
....
Dim stringData As String = Encoding.Default.GetString(dataBuffer)

--
Tom Shelton
Jul 3 '08 #3
On 2008-07-03, Tom Shelton <to*********@comcastXXXXXXX.netwrote:
On 2008-07-03, andrewb <aj*****@deloitte.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.Default.GetBytes(stringData)
WriteFile(......)
' receive data
ReadFile(...dataBuffer...)
...
Dim stringData As String = Encoding.Default.GetString(dataBuffer)
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\MServerPipe"
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_DUPLEX Or FILE_FLAG_WRITE_THROUGH
pipeMode = PIPE_WAIT Or PIPE_TYPE_MESSAGE Or
PIPE_READMODE_MESSAGE

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

res = ConnectNamedPipe(hPipe, 0)

res = ReadFile(hPipe, dataIn, 256, nChars, 0)
stringIn = System.Text.Encoding.ASCII.GetString(dataIn)

CloseHandle(hPipe)

Client code
========

Dim pipeName As String = "\\.\pipe\MServerPipe"

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.Encoding.ASCII.GetBytes(stringOut)

res = CallNamedPipe(pipeName, dataOut, stringOut.Length,
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 nNumberOfBytesToWrite As Integer, ByRef
lpNumberOfBytesWritten As Integer, _
ByVal lpOverlapped As Integer _
) As Integer

Declare Function ReadFile Lib "kernel32" _
(ByVal hFile As Integer, ByVal lpBuffer() As Byte, _
ByVal nNumberOfBytesToRead As Integer, ByRef
lpNumberOfBytesRead As Integer, _
ByVal lpOverlapped As Integer _
) As Integer
Jul 3 '08 #5
"andrewb" <aj*****@deloitte.co.ukschrieb:
Dim pipeName As String = "\\.\pipe\MServerPipe"

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 nNumberOfBytesToWrite As Integer, ByRef
lpNumberOfBytesWritten 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*****@deloitte.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\MServerPipe"
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_DUPLEX Or FILE_FLAG_WRITE_THROUGH
pipeMode = PIPE_WAIT Or PIPE_TYPE_MESSAGE Or
PIPE_READMODE_MESSAGE

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

res = ConnectNamedPipe(hPipe, 0)

res = ReadFile(hPipe, dataIn, 256, nChars, 0)
stringIn = System.Text.Encoding.ASCII.GetString(dataIn)

CloseHandle(hPipe)

Client code
========

Dim pipeName As String = "\\.\pipe\MServerPipe"

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.Encoding.ASCII.GetBytes(stringOut)

res = CallNamedPipe(pipeName, dataOut, stringOut.Length,
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 nNumberOfBytesToWrite As Integer, ByRef
lpNumberOfBytesWritten As Integer, _
ByVal lpOverlapped As Integer _
) As Integer

Declare Function ReadFile Lib "kernel32" _
(ByVal hFile As Integer, ByVal lpBuffer() As Byte, _
ByVal nNumberOfBytesToRead As Integer, ByRef
lpNumberOfBytesRead 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(BUFFSIZE) As Byte
Dim bytesRead As Integer

'Call the CallNamedPipe function to do the transactions
CallNamedPipe(pipeName, outBuffer, outBuffer.Length, inBuffer, inBuffer.Length, bytesRead, 30000)
Console.WriteLine(Encoding.ASCII.GetString(inBuffe r, 0, bytesRead))
End Sub

Private Const pipeName As String = "\\.\pipe\MyPipe"
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\MyPipe"
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_DUPLEX Or FILE_FLAG_WRITE_THROUGH
pipeMode = PIPE_WAIT Or PIPE_TYPE_MESSAGE Or PIPE_READMODE_MESSAGE

hPipe = CreateNamedPipe(pipeName, openMode, pipeMode, 10, 10000, 2000, 10000, IntPtr.Zero)
If hPipe <INVALID_HANDLE_VALUE Then
Console.WriteLine("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(BUFFSIZE) As Byte

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

Do
ConnectNamedPipe(hPipe, IntPtr.Zero)

''Read the data sent by the client over the pipe
cbnCount = BUFFSIZE
ReadFile(hPipe, inputBuffer, inputBuffer.Length, cbnCount, IntPtr.Zero)
Console.WriteLine("Client Says {0}", Encoding.ASCII.GetString(inputBuffer, 0, cbnCount))
WriteFile(hPipe, outBuffer, outBuffer.Length, cbnCount, IntPtr.Zero)
'res = FlushFileBuffers(hPipe)
''Disconnect the named pipe.
DisconnectNamedPipe(hPipe)
'Loop until the client makes no more requests for data.
Loop Until byteCount = 0

Console.WriteLine("Read or Write completed")

'Close the pipe handle when the client makes no requests
CloseHandle(hPipe)
Console.WriteLine("Disconnected the named pipe")
Else
Console.WriteLine("Pipe creation failed")
End If
End Sub

Public Const FILE_ATTRIBUTE_NORMAL As Short = &H80S
Public Const FILE_FLAG_NO_BUFFERING As Integer = &H20000000
Public Const FILE_FLAG_WRITE_THROUGH As Integer = &H80000000

Public Const PIPE_ACCESS_DUPLEX As Short = &H3S
Public Const PIPE_READMODE_MESSAGE As Short = &H2S
Public Const PIPE_TYPE_MESSAGE 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 lpSecurityAttributes As IntPtr _
) As IntPtr

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

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

Declare Function WriteFile Lib "kernel32" ( _
ByVal hFile As IntPtr, _
ByVal lpBuffer() As Byte, _
ByVal nNumberOfBytesToWrite As Integer, _
ByRef lpNumberOfBytesWritten As Integer, _
ByVal lpOverlapped As IntPtr _
) As Integer

Declare Function ReadFile Lib "kernel32" ( _
ByVal hFile As IntPtr, _
ByVal lpBuffer() As Byte, _
ByVal nNumberOfBytesToRead As Integer, _
ByRef lpNumberOfBytesRead As Integer, _
ByVal lpOverlapped As IntPtr _
) As Integer

Declare Function FlushFileBuffers 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...@comcastXXXXXXX.netwrote:
On 2008-07-03, andrewb <ajba...@deloitte.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\MServerPipe"
* * * * 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_DUPLEX Or FILE_FLAG_WRITE_THROUGH
* * * * pipeMode = PIPE_WAIT Or PIPE_TYPE_MESSAGE Or
PIPE_READMODE_MESSAGE
* * * * hPipe = CreateNamedPipe(pipeName, openMode, pipeMode,10,
10000, 2000, 10000, IntPtr.Zero)
* * * * res = ConnectNamedPipe(hPipe, 0)
* * * * res = ReadFile(hPipe, dataIn, 256, nChars, 0)
* * * * stringIn = System.Text.Encoding.ASCII.GetString(dataIn)
* * * * CloseHandle(hPipe)
Client code
========
* * * * Dim pipeName As String = "\\.\pipe\MServerPipe"
* * * * 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.Encoding.ASCII.GetBytes(stringOut)
* * * * res = CallNamedPipe(pipeName, dataOut, stringOut.Length,
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 nNumberOfBytesToWrite As Integer, ByRef
lpNumberOfBytesWritten As Integer, _
* * ByVal lpOverlapped As Integer _
* * ) As Integer
* * Declare Function ReadFile Lib "kernel32" _
* * * * (ByVal hFile As Integer, ByVal lpBuffer() As Byte, _
* * * * * * ByVal nNumberOfBytesToRead As Integer, ByRef
lpNumberOfBytesRead 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(BUFFSIZE) As Byte
* * * * Dim bytesRead As Integer

* * * * 'Call the CallNamedPipe function to do the transactions
* * * * CallNamedPipe(pipeName, outBuffer, outBuffer.Length, inBuffer, inBuffer.Length, bytesRead, 30000)
* * * * Console.WriteLine(Encoding.ASCII.GetString(inBuffe r, 0, bytesRead))
* * End Sub

* * Private Const pipeName As String = "\\.\pipe\MyPipe"
* * 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\MyPipe"
* * 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_DUPLEX Or FILE_FLAG_WRITE_THROUGH
* * * * pipeMode = PIPE_WAIT Or PIPE_TYPE_MESSAGE Or PIPE_READMODE_MESSAGE

* * * * hPipe = CreateNamedPipe(pipeName, openMode, pipeMode, 10, 10000, 2000, 10000, IntPtr.Zero)
* * * * If hPipe <INVALID_HANDLE_VALUE Then
* * * * * * Console.WriteLine("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(BUFFSIZE) As Byte

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

* * * * * * Do
* * * * * * * * ConnectNamedPipe(hPipe, IntPtr.Zero)

* * * * * * * * ''Read the data sent by the client over the pipe
* * * * * * * * cbnCount = BUFFSIZE
* * * * * * * * ReadFile(hPipe, inputBuffer, inputBuffer.Length, cbnCount, IntPtr.Zero)
* * * * * * * * Console.WriteLine("Client Says {0}", Encoding.ASCII.GetString(inputBuffer, 0, cbnCount))

* * * * * * * * WriteFile(hPipe, outBuffer, outBuffer.Length, cbnCount, IntPtr.Zero)
* * * * * * * * 'res = FlushFileBuffers(hPipe)
* * * * * * * * ''Disconnect the named pipe.
* * * * * * * * DisconnectNamedPipe(hPipe)
* * * * * * * * 'Loop until the client makes no more requests for data.
* * * * * * Loop Until byteCount = 0

* * * * * * Console.WriteLine("Read or Write completed")

* * * * * * 'Close the pipe handle when the client makes no requests
* * * * * * CloseHandle(hPipe)
* * * * * * Console.WriteLine("Disconnected the named pipe")
* * * * Else
* * * * * * Console.WriteLine("Pipe creation failed")
* * * * End If
* * End Sub

* * Public Const FILE_ATTRIBUTE_NORMAL As Short = &H80S
* * Public Const FILE_FLAG_NO_BUFFERING As Integer = &H20000000
* * Public Const FILE_FLAG_WRITE_THROUGH As Integer = &H80000000

* * Public Const PIPE_ACCESS_DUPLEX As Short = &H3S
* * Public Const PIPE_READMODE_MESSAGE As Short = &H2S
* * Public Const PIPE_TYPE_MESSAGE 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 lpSecurityAttributes As IntPtr _
* * ) As IntPtr

* * Declare Function ConnectNamedPipe Lib "kernel32" ( _
* * * * ByVal hNamedPipe As IntPtr, _
* * * * ByVal lpOverlapped As IntPtr _
* * ) As Boolean

* * Declare Function DisconnectNamedPipe Lib "kernel32" ( _
* * * * ByVal hNamedPipe As IntPtr _
* * ) As Boolean

* * Declare Function WriteFile Lib "kernel32" ( _
* * * * ByVal hFile As IntPtr, _
* * * * ByVal lpBuffer() As Byte, _
* * * * ByVal nNumberOfBytesToWrite As Integer, _
* * * * ByRef lpNumberOfBytesWritten As Integer, _
* * * * ByVal lpOverlapped As IntPtr _
* * ) As Integer

* * Declare Function ReadFile Lib "kernel32" ( _
* * * * ByVal hFile As IntPtr, _
* * * * ByVal lpBuffer() As Byte, _
* * * * ByVal nNumberOfBytesToRead As Integer, _
* * * * ByRef lpNumberOfBytesRead As Integer, _
* * * * ByVal lpOverlapped As IntPtr _
* * ) As Integer

* * Declare Function FlushFileBuffers 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
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...
5
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...
2
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...
4
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...
2
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...
5
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;...
1
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...
2
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...
1
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()...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

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.