i've got a problem mapping a network drive (WebDAV) under Windows XP using API method WNetAddConnection2. Under Windows 7 or it works like a charme. My code:
function ConnectDrive(Drive: string; Folder: string;
Username: string; Password: string; RestoreAtLogon: Boolean): HRESULT;
var
NetResource: TNetResource;
dwFlags: DWORD;
begin
with NetResource do
begin
dwType := RESOURCETYPE_DISK;
lpLocalName := PChar(Drive);
lpRemoteName := PChar(Folder);
lpProvider := nil;
end;
if (RestoreAtLogon) then
dwFlags := CONNECT_UPDATE_PROFILE
else
dwFlags := 0;
Result := WNetAddConnection2(NetResource, PChar(Password),
PChar(Username), dwFlags);
end;
Everytime i try to connect Windows tells me: "The Network name cannot be found" or "The Network path cannot be found"
As i said before, under Windows 7 there is no problem.
If i use commercial tools like Netdrive, this program has no problem mounting the drive under XP, Vista or Windows 7.
Has anyone an idea?
Thanks in advance