首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

WNetAddConnection2放回error53如何解决?

2012-09-24 
WNetAddConnection2放回error53怎么解决?救命啊!!!!!!CString netpath\\\\+ipAddr+\\+FileStoreParti

WNetAddConnection2放回error53怎么解决?救命啊!!!!!!
CString netpath="\\\\"+ipAddr+"\\"+FileStorePartion;//+"$";//共享资源的网络路径
//路径最后得到的是netpath="\\192.168.1.106\d";
NETRESOURCE netres; 
//netres.dwScope = RESOURCE_GLOBALNET; 
netres.dwScope=RESOURCE_CONNECTED;  
//netres.dwType = RESOURCETYPE_DISK;
netres.dwType=RESOURCETYPE_ANY;  
netres.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE;//RESOURCEDISPLAYTYPE_GENERIC; 
netres.dwUsage = RESOURCEUSAGE_CONNECTABLE; 
netres.lpLocalName = NULL; //映射网络驱动器
netres.lpRemoteName = (LPTSTR)(LPCTSTR)netpath; 
netres.lpComment = NULL; 
netres.lpProvider = NULL; 



DWORD ConnectFlag=WNetAddConnection2(&netres,UserPassword,UserName,NULL);

通过网上邻居可以正常访问共享文件数据
dos命令下也可以正常连接
连接用的用户名和密码是服务器新创建的超级用户
按道理没问题的,服务器上设置也没问题,都能够正常访问,代码就是过不去,老是返回53错误码
上个星期就要交工的,现在还没完成,求各位大神帮忙啊!!!!

[解决办法]

C/C++ code
#include "stdafx.h"#include <windows.h>#include <stdio.h>#include <winnetwk.h>#pragma comment(lib, "mpr.lib")int _tmain(int argc, _TCHAR* argv[]){  //  // Assign values to the NETRESOURCE structure.  //  NETRESOURCE nr = {0};  nr.dwType = RESOURCETYPE_ANY;  nr.lpLocalName = _T("Q:");  nr.lpRemoteName = _T("\\\\192.168.0.66\\SharedDocs");//  //  // Call the WNetAddConnection2 function to assign  //   a drive letter to the share.  //  DWORD res = WNetAddConnection2(&nr, NULL, NULL, 0);  //  // If the call succeeds, inform the user; otherwise,  //  print the error.  //  if(res != NO_ERROR)  {    #define caseErr(x) case(x): { printf(#x "\n"); break;  }    switch(res)    {      caseErr(ERROR_ACCESS_DENIED); //The caller does not have access to the network resource.      caseErr(ERROR_ALREADY_ASSIGNED); //The local device specified by the lpLocalName member is already connected to a network resource.      caseErr(ERROR_BAD_DEV_TYPE); //The type of local device and the type of network resource do not match.      caseErr(ERROR_BAD_DEVICE); //The value specified by lpLocalName is invalid.      caseErr(ERROR_BAD_NET_NAME); //The value specified by the lpRemoteName member is not acceptable to any network resource provider, either because the resource name is invalid, or because the named resource cannot be located.      caseErr(ERROR_BAD_PROFILE); //The user profile is in an incorrect format.      caseErr(ERROR_BAD_PROVIDER); //The value specified by the lpProvider member does not match any provider.      caseErr(ERROR_BUSY); //The router or provider is busy, possibly initializing. The caller should retry.      caseErr(ERROR_CANCELLED); //The attempt to make the connection was canceled by the user through a dialog box from one of the network resource providers, or by a called resource.      caseErr(ERROR_CANNOT_OPEN_PROFILE); //The system is unable to open the user profile to process persistent connections.      caseErr(ERROR_DEVICE_ALREADY_REMEMBERED); //An entry for the device specified by lpLocalName is already in the user profile.      caseErr(ERROR_EXTENDED_ERROR); //A network-specific error occurred. Call the WNetGetLastError function to obtain a description of the error.      caseErr(ERROR_INVALID_PASSWORD); //The specified password is invalid and the CONNECT_INTERACTIVE flag is not set.      caseErr(ERROR_NO_NET_OR_BAD_PATH); //The operation cannot be performed because a network component is not started or because a specified name cannot be used.      caseErr(ERROR_NO_NETWORK); //The network is unavailable.    default:      {        printf("Error: %ld\n", res);      }    }   }  return 0;}
[解决办法]
53: 找不到网络路径。

热点排行