Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
24
Добавлен:
06.02.2018
Размер:
797 б
Скачать
#include <windows.h>
#include <stdio.h>

int main()
{
	char buffer[100] = "Readed...";
	DWORD actlen;
	HANDLE hstdin, hstdout;
	BOOL rc;
	
	hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
	if (hstdout == INVALID_HANDLE_VALUE) {
	  printf("Error of GetStdHandle = %d", hstdout);
	  return(0);
	}
	printf("OutHNDL: %d \r\n", hstdout);
	fflush(stdout);
	
	hstdin = GetStdHandle(STD_INPUT_HANDLE);
	if (hstdin == INVALID_HANDLE_VALUE) {
	  printf("Error of GetStdHandle hstdin = %d", hstdin);
	  return(0);
	}
	printf("InHNDL: %d \r\n", hstdin);
	fflush(stdout);
	
	printf("Enter something: ");
	fflush(stdout);
	
	rc = ReadFile(hstdin, buffer+ 18, 80, &actlen, NULL);
	if(!rc)
	  return(0);
	actlen += 18;
	WriteFile(hstdout, buffer, actlen, &actlen, 0);
	getchar();
}