首页  编辑  

映射网络驱动器

Tags: /超级猛料/Network.网络通讯/LAN/   Date Created:

]、。·ˉˇ¨〃々—~‖…’”〕〉》」』〗】∶!"'),.:;?]` 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;