Z
zla
Unregistered / Unconfirmed
GUEST, unregistred user!
我用如下方式
if MapDir('Z:','//192.168.0.1/Share','administrator','123') then
form1.caption:='成功'
else
Form1.caption:='失败'
用如上的方法映射驱动器,有时成功,有时失败,是为什么呢
function MapDir(aDirName,aShareDir,UserName,Pwd:string) : Boolean;
var
netRes: TNetResource;
begin
begin
with netRes do
begin
dwType := RESOURCETYPE_DISK;
lpLocalName := PChar(aDirName);
lpRemoteName :=PChar(aShareDir);
lpProvider := nil;
end;
if WNetAddConnection3(Application.Handle, netRes,PChar(Pwd), pchar(UserName),
CONNECT_UPDATE_PROFILE)=NO_ERROR then
Result:=True
else
Result:=False;
end;
end;
if MapDir('Z:','//192.168.0.1/Share','administrator','123') then
form1.caption:='成功'
else
Form1.caption:='失败'
用如上的方法映射驱动器,有时成功,有时失败,是为什么呢
function MapDir(aDirName,aShareDir,UserName,Pwd:string) : Boolean;
var
netRes: TNetResource;
begin
begin
with netRes do
begin
dwType := RESOURCETYPE_DISK;
lpLocalName := PChar(aDirName);
lpRemoteName :=PChar(aShareDir);
lpProvider := nil;
end;
if WNetAddConnection3(Application.Handle, netRes,PChar(Pwd), pchar(UserName),
CONNECT_UPDATE_PROFILE)=NO_ERROR then
Result:=True
else
Result:=False;
end;
end;