用delphi来"映射网络驱动器"?(20分)

  • 主题发起人 主题发起人 tang_zhihua
  • 开始时间 开始时间
T

tang_zhihua

Unregistered / Unconfirmed
GUEST, unregistred user!
请问各位大哥大姐要怎样写才吗?
 
procedure TForm1.Button1Click(Sender: Tobject);
var
NetR :NETRESOURCE;ErrInfo : Longint;
begin
NetR.dwScope := RESOURCE_GLOBALNET;
NetR.dwType := RESOURCETYPE_DISK;
NetR.dwDisplayType := RESOURCEDISPLAYTYPE_SHARE;
NetR.dwUsage := RESOURCEUSAGE_CONNECTABLE;
NetR.lpLocalName := 'j:';
NetR.lpRemoteName := '//Lifang/c';
ErrInfo := WNetAddConnection2(NetR, '', '', CONNECT_UPDATE_PROFILE);
If ErrInfo = NO_ERROR Then
messagebox(0,'Net connection successful!','',0)
Else
messagebox(0,'ERROR: ','',0);
end;

断开映射网络驱动器
procedure TForm1.Button2Click(Sender: Tobject);
var
ErrInfo : Longint;
strLocalName : pchar;
begin
strLocalName:='j:';
ErrInfo := WNetCancelConnection2(strLocalName, CONNECT_UPDATE_PROFILE,False);
If ErrInfo = NO_ERROR Then
messagebox(0,'Net disconnection successful!','',0)
Else
messagebox(0,'ERROR','',0);
end;
 
映射网络驱动器以后,这个驱动器的卷标非常不好看,要怎么才能修改呢?用SetVolumeLabel函数不能修改,用dos下的label命令也不行,在注册表里面也找不到对应的字符串,但是用手工却又可以修改,郁闷,请哪位知道的大侠讲讲怎么修改,谢谢!
 
procedure TForm1.Button1Click(Sender: Tobject);
var
NetR :NETRESOURCE;ErrInfo : Longint;
begin
NetR.dwScope := RESOURCE_GLOBALNET;
NetR.dwType := RESOURCETYPE_DISK;
NetR.dwDisplayType := RESOURCEDISPLAYTYPE_SHARE;
NetR.dwUsage := RESOURCEUSAGE_CONNECTABLE;
NetR.lpLocalName := 'j:'; {这为映射网驱动器}
NetR.lpRemoteName := '//sdl052/share';{这为映射网络路径,sdl052是电脑名称,share是共享名}
ErrInfo := WNetAddConnection2(NetR, '', '', CONNECT_UPDATE_PROFILE);
If ErrInfo = NO_ERROR Then
messagebox(0,'Net connection successful!','',0)
Else
messagebox(0,'ERROR: ','',0);
end;

yangxiao_jiang为什么会提示"RROR"请指教.谢谢!
 
接受答案了.
 

Similar threads

回复
0
查看
846
不得闲
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部