CreateNamedPipe() - Invalid memory access.
Posted: Sun Oct 23, 2005 11:20 am
Hi,
I keep getting an "Invalid memory access" error when executing CreateNamedPipe() function. I looked at other examples and checked the parameters but can't find what I'm doing wrong here.
I keep getting an "Invalid memory access" error when executing CreateNamedPipe() function. I looked at other examples and checked the parameters but can't find what I'm doing wrong here.
Code: Select all
; Program to create a named pipe and call the pipe with CallNamedPipe().
#BUFSIZE = 1024
lpszPipeName.s = "\\.\pipe\mynamedpipe"
CallDebugger
hPipe.l = CreateNamedPipe_(lpszPipename, #PIPE_ACCESS_DUPLEX, #PIPE_TYPE_MESSAGE | #PIPE_READMODE_MESSAGE | #PIPE_WAIT, #PIPE_UNLIMITED_INSTANCES, #BUFSIZE, #BUFSIZE, 20000, #Null)
If hPipe = #INVALID_HANDLE_VALUE
End
EndIf
DefType.b CallResult
;Using API function.
;BOOL CallNamedPipe(
; LPCTSTR lpNamedPipeName,
; LPVOID lpInBuffer,
; DWORD nInBufferSize,
; LPVOID lpOutBuffer,
; DWORD nOutBufferSize,
; LPDWORD lpBytesRead,
; DWORD nTimeOut
;);
lpInBuffer.s = "This is a message from PureBasic."
nInBufferSize.l = Len(lpInBuffer)
lpOutBuffer.s = Space(#BUFSIZE)
lpBytesRead.l = 0
; Keep getting an invalid Memory access on the mext line. What am I doing wrong?
CallResult = CallNamedPipe_(hPipe, lpInBuffer, nInBufferSize, lpOutBuffer, #BUFSIZE, @lpBytesRead, #NMPWAIT_USE_DEFAULT_WAIT)
End ; Of main program