I have tried creating a named pipe but getting GLE 5 (access denied Error)
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <tchar.h>
#include "iostream.h"
//#define PIPE_ACCESS_DUPLEX 0x00000003
//#define PIPE_ACCESS_INBOUND 0x00000001
//#define PIPE_ACCESS_OUTBOUND 0x00000002
#define BUFSIZE 512
int main()
{
HANDLE hPipe;
LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\mynamedpipe");
hPipe=CreateNamedPipe(lpszPipename,PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,PIPE_UNLIMITED_INSTANCES,BUFSIZE,BUFSIZE,0,NULL);
if (hPipe != INVALID_HANDLE_VALUE)
cout<<"Valid";
if (GetLastError() != ERROR_PIPE_BUSY)
{
printf( TEXT("Could not open pipe. GLE=%d\n"), GetLastError() );
return -1;
}
return 0;
}
Well I tried around a lot of things with my programme but was not able to find out why the creation is failed.
I was working on VC++ 6.0 . Then I started my Visual Studio 2008 and created a C++ project. Pasted the Code . Compiled. Got the error :
commented
#include "iostream.h".Rebuild and that worked . Not very sure why this happened , but worked for me. Please update if you got to know why this is happening or there is a solution.