本帖最后由 linguangdong 于 2009-08-06 21:44:38 编辑

解决方案 »

  1.   


    我试验的结果是,如果直接连,很可能连不上,
    但如果你用 win键 + R ,然后输入目标机器地址,手动连接到目标机器上
    然后再运行程序就可以连上了
      

  2.   

    先与目标机器建立IPC连接试试看
    一种办法是在程序中执行命令
    net use \\ip\\ipc$ password /user:user 
    user和password是你用于访问的用户名和密码
    另一种办法是用下面的程序建立IPC连接BOOL ConnetIPC(char * RemoteName,char * User,char * PassWord) 

      char tmp[128]="\\\\"; 
     strcat(tmp,RemoteName); 
     strcat(tmp,"\\ipc$"); 
     NETRESOUCE NetResouce; 
     NetResouce.lpRemoteName=tmp; 
     NetResouce.dwType=RESOURCETYPE_ANY; 
     NetResouce.lpProvider=NULL; 
     if (WnetAddConnection2(&NetResouce,PassWord,User,FLASE)==NO_ERROR) 
      //建立连接! 
      return FALSE; 
     else 
      return TRUE; 

      

  3.   


    SECURITY_ATTRIBUTES     sa;
    SECURITY_DESCRIPTOR     sd; if( InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION) )
    {
    // add a NULL disc. ACL to the
    // security descriptor.
    if (SetSecurityDescriptorDacl(&sd, TRUE, (PACL) NULL, FALSE))
    {
    sa.nLength = sizeof(sa);
    sa.lpSecurityDescriptor =&sd;
    sa.bInheritHandle = TRUE; //在这里
    CreateNamedPipe(.......&sa);
    }

    }主要因为你的权根不够.