uses
Windows;
procedure DoLogOn(var RemotePath: String; const UserName: String;
const Password: String);
var
NR: TNetResource;
Win32Result: Integer;
begin
{ Check local path }
if (RemotePath = '') or (Copy(RemotePath,1,2) <> '\\') then
begin
Exit;
end;
RemotePath := ExcludeTrailingPathDelimiter(RemotePath);
with NR do
begin
dwType := RESOURCETYPE_ANY;
lpLocalName := nil;
lpRemoteName := PChar(RemotePath);
lpProvider := nil;
end;
Win32Result := WNetAddConnection2(NR,PChar(Password),
PChar(UserName),0);
if Win32Result <> NO_ERROR then
begin
RaiseLastOSError(Win32Result);
end;
end;
procedure DoLogOff(const RemotePath: String);
var
Pathname: String;
Win32Result: Integer;
begin
{ Check local path }
if (RemotePath = '') or (Copy(RemotePath,1,2) <> '\\') then
begin
Exit;
end;
Win32Result := WNetCancelConnection2(PChar(Pathname),0,False);
if Win32Result <> NO_ERROR then
begin
RaiseLastOSError(Win32Result);
end;
end;
Object Pascal
0 件のコメント:
コメントを投稿