Cześć
Próbuję napisać prosty klient FastCGI dla IIS, ale mam problem z dostaniem się do potoku IIS'a.
Funkcja CreateFile zawsze zwraca ERROR_PIPE_BUSY. Jak poprawnie dostać uchwyt potoku i wysłać odpowiedź?

#include <Windows.h>
#include <stdio.h>

#pragma warning(disable : 4996)

static void Log(const char * log, int logLen)
{
	FILE *	file;

	file = fopen("C:\\tmp\\log.log", "ab");
	fwrite(log, 1, logLen, file);
	fwrite("\n", 1, 1, file);
	fclose(file);
}
static void LogTxt(const char * log)
{
	Log(log, strlen(log));
}
static void LogErrCode(const char * log, int logLen, int err)
{
	char	buf[1024];

	itoa(err, buf, 10);

	strcat(buf, log);
	LogTxt(buf);
}

 int main(int argc, char * argv[])
{
	HANDLE		pipe;
	BOOL		fSuccess = FALSE;
	wchar_t		pipeName[1024];

	LogTxt(getenv("_FCGI_X_PIPE_"));

	while (1)
	{
		pipe = CreateFileA(getenv("_FCGI_X_PIPE_"), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

		// Break if the pipe handle is valid. 
		if (pipe != INVALID_HANDLE_VALUE)
			break;

		// Exit if an error other than ERROR_PIPE_BUSY occurs. 
		if (GetLastError() != ERROR_PIPE_BUSY)
		{
			LogErrCode(" Could not open pipe.", 21, GetLastError());
			return -1;
		}

		// All pipe instances are busy, so wait for 20 seconds. 
		if (!WaitNamedPipeA(getenv("_FCGI_X_PIPE_"), 2000))
		{
			LogErrCode(" Could not open pipe: 2 second wait timed out.", 45, GetLastError());
			return -1;
		}
	}
	return 0;
}