如果编程实现登陆别的计算机的共享目录并映射成本地驱动器?
来自:迷糊, 时间:2005-1-26 9:29:54, ID:2976116
如果你是要映射网络驱动器的话其实不难,看看这个api函数
DWORD WNetAddConnection2(
LPNETRESOURCE lpNetResource, // points to structure that specifies connection details
LPCTSTR lpPassword, // points to password string
LPCTSTR lpUsername, // points to user name string
DWORD dwFlags // set of bit flags that specify connection options
);
function addsharedriver(localname,remotename,username,password:string):boolean;
var
NetSource : TNetResource;
begin
with NetSource do
begin
dwType := RESOURCETYPE_disk;
lpLocalName :=pchar(localname);
lpRemoteName :=pchar(remotename);
lpProvider :='';
end;
result:=WnetAddConnection2(NetSource,pchar(password),pchar(username),CONNECT_UPDATE_PROFILE)=NO_ERROR;
end;
调用:
addsharedriver('X:','//192.168.0.1/share','administrator','1234')