J
jackalan
Unregistered / Unconfirmed
GUEST, unregistred user!
怎么用程序来自动登陆2000下的共享文件夹呀,下面是我用的连接方法,但不行的,不知道什么地方有问题!
Function ConnectLine(strDir,UserName,Password : string) : Boolean;
var
nRes: TNetResource;
begin
result := true;
if MidBstr(strDir,2,2) = ':/' then
begin
exit;
end;
nRes.dwScope := RESOURCE_GLOBALNET;
nRes.dwType := RESOURCETYPE_ANY;
nRes.dwDisplayType := RESOURCEDISPLAYTYPE_SHARE;
nRes.dwUsage := RESOURCEUSAGE_CONNECTABLE;
nRes.lpLocalName := nil;
nRes.lpRemoteName := PChar(strDir);
nRes.lpComment := nil;
nRes.lpProvider := nil;
{f WNetAddConnection(pchar(strDir),pchar(Password),'') <> 0 then
Result := false;}
if UserName = '' then UserName := 'Guest';
if WNetAddConnection2(nRes,Pchar(Password),Pchar(UserName), CONNECT_PROMPT)=0 then
begin
Result := True;
end
else
begin
Result := False;
end;
end;
如果你知道俺感激涕零。。。。。。。。。。
Function ConnectLine(strDir,UserName,Password : string) : Boolean;
var
nRes: TNetResource;
begin
result := true;
if MidBstr(strDir,2,2) = ':/' then
begin
exit;
end;
nRes.dwScope := RESOURCE_GLOBALNET;
nRes.dwType := RESOURCETYPE_ANY;
nRes.dwDisplayType := RESOURCEDISPLAYTYPE_SHARE;
nRes.dwUsage := RESOURCEUSAGE_CONNECTABLE;
nRes.lpLocalName := nil;
nRes.lpRemoteName := PChar(strDir);
nRes.lpComment := nil;
nRes.lpProvider := nil;
{f WNetAddConnection(pchar(strDir),pchar(Password),'') <> 0 then
Result := false;}
if UserName = '' then UserName := 'Guest';
if WNetAddConnection2(nRes,Pchar(Password),Pchar(UserName), CONNECT_PROMPT)=0 then
begin
Result := True;
end
else
begin
Result := False;
end;
end;
如果你知道俺感激涕零。。。。。。。。。。