CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

关于命名管道一源程序运行这没老是不能创建命名管道成功呢?

楼主every()2001-10-31 16:13:16 在 VC/MFC / 基础类 提问

      在网络编程技术关于命名管道一源程序这么总是执行不了?  
    #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

相关问题

  • asp.net运行一次后,源程序能删除吗?
  • Python里怎样运行源程序文件?(请高手别笑)
  • 命名管道
  • 有没有象溯雪程序运行时的那种效果源程序???
  • 源程序
  • c源程序。
  • 求源程序!
  • 急需DES和RAS的加解密源程序,能在32位机上运行,超急!!!
  • 请问你们在网上拷vb 的源程序来运行时, 是不是经常有错误的?例如:
  • 我想把源程序粘贴到TC中运行,TC窗口上边没有工具栏请问怎么调?

关键词

  • 命名
  • null
  • pipehandle
  • 命名管道
  • pipe
  • buffer
  • printf

得分解答快速导航

  • 帖主:every
  • Julienjut

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo