Damit:
Delphi-Quellcode:
uses
Windows;
function ConnectToNetworkDriveW(LocalName: WideString; RemoteName: wideString; Username: WideString; Password: WideString;
RestoreAtLogon: boolean): DWORD;
function DisconnectNetworkDrivew(Name: WideString): DWORD;
implementation
function ConnectToNetworkDriveW(LocalName: WideString; RemoteName: wideString; Username: WideString; Password: WideString;
RestoreAtLogon: boolean): DWORD;
var
NetResource : TNetResourceW;
dwFlags : DWORD;
begin
dwFlags := 0;
ZeroMemory(@NetResource, sizeof(TNetResource));
with NetResource do
begin
dwType := RESOURCETYPE_ANY;
lpLocalName := PWideChar(LocalName);
lpRemoteName := PwideChar(RemoteName);
lpProvider := nil;
end;
if (RestoreAtLogon) then
dwFlags := dwFlags or CONNECT_UPDATE_PROFILE;
Result := WNetAddConnection2W(NetResource, PWideChar(Password), PWideChar(Username), dwFlags);
end;
function DisconnectNetworkDrivew(Name: WideString): DWORD;
begin
result := WNetCancelConnection2W(PWideChar(Name), CONNECT_UPDATE_PROFILE, True);
end;
Autentifiziere ich mich mit meinem Usermanager an einem anderen PC.