So kannst du eine Freigabe erzeugen:
Delphi-Quellcode:
function ConnectToNetworkDrive(LocalName: string;
RemoteName: string; Username: string; Password: string;
RestoreAtLogon: boolean ): DWORD;
var
NetResource: TNetResource;
dwFlags: DWORD;
begin
dwFlags := 0;
ZeroMemory(@NetResource, sizeof(TNetResource));
with NetResource do begin
dwType := RESOURCETYPE_DISK;
lpLocalName := PChar(LocalName);
lpRemoteName := PChar(RemoteName);
lpProvider := nil;
end;
if (RestoreAtLogon) then
dwFlags := dwFlags or CONNECT_UPDATE_PROFILE;
Result := WNetAddConnection2(NetResource,PChar(Password), PChar(Username),dwFlags);
end;
function DisconnectNetworkDrive(Name: String): DWORD;
begin
result := WNetCancelConnection2(PChar(Name), CONNECT_UPDATE_PROFILE, True);
end;