// eeeee.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <windows.h>
#include <conio.h>
#include <stdio.h>
#include <iostream.h>
int main(int argc, char* argv[])
{
	
	HANDLE PipeHandle;
	DWORD BytesRead;
	DWORD BytesWritten;
	CHAR buffer[256];
	CHAR otvet[256];
	DWORD Ret;
	char b[256];
	if ((PipeHandle=CreateFile("\\\\.\\pipe\\sdf",GENERIC_WRITE, FILE_SHARE_READ, NULL,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL))==INVALID_HANDLE_VALUE)
	{
		printf ("Create...Error%d\n", GetLastError());
		return 0;
	}
	//printf("Server is NOW running\n");

	cout<<"Enter Message\n";
	cin>>b;
	/*if (ConnectNamedPipe(PipeHandle, NULL)==0)
	{
		printf("Connect///error%d\n",GetLastError());
		CloseHandle(PipeHandle);
		return 0;
	}
	if(Ret= ReadFile(PipeHandle,buffer,sizeof(buffer), &BytesRead, NULL)<=0)
	{
		printf("Read error%d\n",GetLastError());
		printf("%i\n",Ret);
		CloseHandle(PipeHandle); 
		return 0;
	}
	buffer[BytesRead]='\0';
	printf ("%.*s\n",BytesRead, buffer);
	gets(otvet);*/
	if(WriteFile(PipeHandle, b, strlen(b),&BytesWritten,NULL)==0)
	{
		printf ("write///error%d\n", GetLastError());
		CloseHandle(PipeHandle);
		return 0;
	}

	DisconnectNamedPipe(PipeHandle);
	CloseHandle(PipeHandle);
	return 0;
}
