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

delphi WNetAddConnection2 照射網絡驅去問題

2012-12-15 
delphi WNetAddConnection2 映射網絡驅去問題 提示: ERROR_NO_NET_OR_BAD_PATH

delphi WNetAddConnection2 映射網絡驅去問題
 提示:' ERROR_NO_NET_OR_BAD_PATH'
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.代碼如如下..>>>>>>>>>>>>>>>>
spath:='\\192.170.111.9\';
  UName:=PChar('administrator');
  pwd:=PChar('longlongago');
  with netsorce do
  begin
    dwType:=RESOURCETYPE_DISK;
    lpLocalName:='v:';
    lpRemoteName:=PAnsiChar(spath);
    lpProvider:='';
  end;
 case WNetAddConnection2(netsorce,@UName,@pwd,CONNECT_UPDATE_PROFILE) of

   NO_ERROR: ShowMessage('成功') ;
   ERROR_ACCESS_DENIED: showmessage('Access is denied.');
   ERROR_ALREADY_ASSIGNED:ShowMessage('The device specified in the lpLocalName parameter is already connected.');
   ERROR_BAD_DEV_TYPE:ShowMessage('The device type and the resource type do not match.');
   ERROR_BAD_DEVICE:ShowMessage('The value specified in lpLocalName is invalid');
   ERROR_BAD_NET_NAME:ShowMessage('The value specified in the lpRemoteName parameter is not valid or cannot be located.');
   ERROR_BAD_PROFILE :ShowMessage('The user profile is in an incorrect format.')   ;
   ERROR_CANNOT_OPEN_PROFILE :ShowMessage('The system is unable to open the user profile to process persistent connections.    ');
   ERROR_DEVICE_ALREADY_REMEMBERED:ShowMessage('An entry for the device specified in lpLocalName is already in the user profile.') ;
   ERROR_EXTENDED_ERROR:ShowMessage('A network-specific error occurred. To get a description of the error, use the WNetGetLastError function. ');
   ERROR_INVALID_PASSWORD:ShowMessage('The specified password is invalid. ');
   ERROR_NO_NET_OR_BAD_PATH:ShowMessage('The operation cannot be performed because either a network component is not started or the specified name cannot be used.');
   ERROR_NO_NETWORK:ShowMessage('The network is not present. ');
 else
   ShowMessage('其他意外終止!');

 end;
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[解决办法]
如果地址栏里打
\\192.170.111.9\d$
回车后,会弹出登录框,输入用户名有密码可以成功显示对方目录的话,按下面改:

spath:='\\192.170.111.9\';
改为
spath:='\\192.170.111.9\d$';
再试下

你要给个路径的,至少也要有对方的盘符 c$ d$ c$\temp d$\test这样的
[解决办法]
你也可以在命令行下使用

net use z: \\192.170.111.9\d$ longlongago /user:administrator

试验是否连接成功

如成功会显示:“命令成功完成”,否则会报错

热点排行