I am trying to create a named pipe in vc++. I am used to C and I hope that the error is not just related to me not being familiar with c++. The code I am using is the following:
#ifdef DEBUG
printf("%s\n%s\n", this->pipe_name, this->pipe_path);
#endif
this->pipe = CreateNamedPipe(
this->pipe_path,
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_NOWAIT,
1,
this->pipe_buffer_size_kb * 1024,
this->pipe_buffer_size_kb * 1024,
NMPWAIT_USE_DEFAULT_WAIT,
NULL);
if (this->pipe != INVALID_HANDLE_VALUE) // Setup successful
return true;
if (GetLastError() != ERROR_PIPE_BUSY) // Some unexpected error occured
{
#ifdef DEBUG
printf("Failed to create named pipe: %d\n", GetLastError());
#endif
return false;
}
pipe_buffer_size_kb is 8
The output I am getting is the following:
>.\run.exe
p0
\\.\rftb\p0
Failed to create named pipe: 3
As an IDE I use Microsoft Visual Studio Community 2017 (Product details: Microsoft Visual Basic 2017) I've used an empty project template and added DEBUG and _CRT_SECURE_NO_WARNINGS as preprocessor definitions.
Any help is appreciated.