Making a Network Connection in XP

Hi All,

A couple of days ago I had a problem connecting to a Network Share using XP.
But now I have a solution which works in WIN98 and XP so here is the code.
It works fine. Thanks to anyone who reponded to my previous question here's
the answer :)

function NetUse(LokaleRessource,RemoteRessource: String) : Integer;
{ This routine allows you to connect a network drive.
  Example: NetUse(U:,\\GENTKBF1\SYS connects the local drive u: with the
network
  volume SYS from server \\GENTKBF1
  Possible returne values are:

  Value                         Meaning
  ERROR_ACCESS_DENIED         Access is denied.
  ERROR_ALREADY_ASSIGNED The device specified in the lpLocalName parameter
is already connected.
  ERROR_BAD_DEV_TYPE         The device type and the resource type do not
match.
  ERROR_BAD_DEVICE         The value specified in lpLocalName is invalid.
  ERROR_BAD_NET_NAME         The value specified in the lpRemoteName
parameter is not valid or cannot be located.
  ERROR_BAD_PROFILE         The user profile is in an incorrect format.
  ERROR_CANNOT_OPEN_PROFILE The system is unable to open the user profile to
process persistent connections.
  ERROR_DEVICE_ALREADY_REMEMBERED An entry for the device specified in
lpLocalName is already in the user profile.
  ERROR_EXTENDED_ERROR         A network-specific error occurred. To get a
description of the error, use the WNetGetLastError function.
  ERROR_INVALID_PASSWORD The specified password is invalid.
  ERROR_NO_NET_OR_BAD_PATH The operation cannot be performed because either
a network component is not started or the specified name cannot be used.
  ERROR_NO_NETWORK         The network is not present.
  }
begin
  Result:=
WNetAddConnection(PChar(RemoteRessource),Nil,PChar(LokaleRessource));
end;

function NetUseDelete(LokaleRessource: String) : Integer;
{ This function coses an existing networc connection.
  Example: the function call NetUseDelete('O:') cancels the connection from
  drive O: to the actually used network recource.
  Possible returne values are:

Value                 Meaning
ERROR_BAD_PROFILE The user profile is in an incorrect format.
ERROR_CANNOT_OPEN_PROFILE The system is unable to open the user profile to
process persistent connections.
ERROR_DEVICE_IN_USE The device is in use by an active process and cannot be
disconnected.
ERROR_EXTENDED_ERROR A network-specific error occurred. To get a description
of the error, use the WNetGetLastError function.
ERROR_NOT_CONNECTED The name specified by the lpName parameter is not a
redirected device, or the system is not currently connected to the device
specified by the parameter.
ERROR_OPEN_FILES There are open files, and the fForce parameter is FALSE

Quote
}

begin
  Result:= WNetCancelConnection(PChar(LokaleRessource),True);
end;

Thanks

Aaron