关于命名管道一源程序运行这没老是不能创建命名管道成功呢?
在网络编程技术关于命名管道一源程序这么总是执行不了?
#include <windows.h>
#include <stdio.h>
void main(void)
{
HANDLE PipeHandle;
DWORD BytesRead;
CHAR buffer[256];
if ((PipeHandle = CreateNamedPipe("\\\\.\\Pipe\\Jim",
PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 1,
0, 0, 1000, NULL)) == INVALID_HANDLE_VALUE)
{
printf("CreateNamedPipe failed with error %d\n",
GetLastError());
return;
}
printf("Server is now running\n");
if (ConnectNamedPipe(PipeHandle, NULL) == 0)
{
printf("ConnectNamedPipe failed with error %d\n",
GetLastError());
CloseHandle(PipeHandle);
return;
}
if (ReadFile(PipeHandle, buffer, sizeof(buffer),
&BytesRead, NULL) <= 0)
{
printf("ReadFile failed with error %d\n", GetLastError());
CloseHandle(PipeHandle);
return;
}
printf("%.*s\n", BytesRead, buffer);
if (DisconnectNamedPipe(PipeHandle) == 0)
{
printf("DisconnectNamedPipe failed with error %d\n",
GetLastError());
return;
}
CloseHandle(PipeHandle);
}
程序运行
CreateNamedPipe failed with error 120
可是我以创建了一个Jim文件夹,
问题点数:50、回复次数:4Top
1 楼Julienjut(秋水)回复于 2001-10-31 16:29:34 得分 50
看这个错误,好象系统不支持呀!Top
2 楼Julienjut(秋水)回复于 2001-10-31 16:44:41 得分 0
兄弟我找到了,原来98下不可以,你换到2000下看看吧!
CreateNamedPipe Return Values
CreateNamedPipe returns a valid handle if it succeeds. If an error occurs, it returns the value (HANDLE)0xFFFFFFFF (a.k.a., INVALID_HANDLE_VALUE).
WARNING
Applications that are compiled under Windows 98 and use CreateNamedPipe will always return failure (INVALID_HANDLE_VALUE).
You may have noticed that many of the functions we’ve described seem to have rudimentary error returns. CreateThread, CreateMutex, CreateProcess, CreatePipe, and CreateNamedPipe, for example, all might fail for a variety of reasons. The system might be low on memory, or a particular mutex might already exist, or a network connection might fail, or a parameter might be invalid. Yet all of these creation functions indicate errors only by returning either FALSE or an invalid handle.
Top
3 楼Julienjut(秋水)回复于 2001-10-31 16:45:13 得分 0
还有更简单的提示:
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Unsupported.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
Top
4 楼every()回复于 2001-10-31 16:59:00 得分 0
谢谢了.Top




