Board index » delphi » WNetAddConnection2: Accessing server without mapping

WNetAddConnection2: Accessing server without mapping

hi,

i need to access some files in a directory but i would like to do this without
mapping to a drive. the software is to be permanently resident on users' pcs
and i wouldn't like to assume control over any of their drive-letters.

is this possible ?? any help gratefully appreciated.

kelvin.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading

 

Re:WNetAddConnection2: Accessing server without mapping


polyes...@my-dejanews.com heeft geschreven in bericht
<6kmide$3h...@nnrp1.dejanews.com>...
|hi,
|
|i need to access some files in a directory but i would like to do this
without
|mapping to a drive. the software is to be permanently resident on users'
pcs
|and i wouldn't like to assume control over any of their drive-letters.
|
|is this possible ?? any help gratefully appreciated.
|
|kelvin.

Kelvin:

You can use WNetAddConnection2 with or without drive mapping. Below is a
wrapper function.

-LoginMap('\\<ServerName>\Volume\Dir\...','KELVIN','SESAME','F')
would login to server <servername> and map F: to
\\ServerName\Volume\Dir\...
Later on, by using F:\...\ , you can access the desired file.

-LoginMap('\\<ServerName>','KELVIN','SESAME','')
does not perform mapping. The only difference is that later on , you would
have to provide a _full_ UNC path for any file you wish to access on
<ServerName>

Hope this helps.

Regards,
Dirk Claessens
______________________________________________
dirk.claessens@village.#NOSPAM#uunet.be
dirk.claessens.dc@belgium.#NOSPAM#agfa.com
remove #NOSPAM#  from mailheader
______________________________________________

(***********************************************************)
function LoginMap(UNCPath,UserName,PassWord,MapDrive:string):integer;
var
 NwR : TNetResource;
begin
  with NwR do begin
    dwType      := RESOURCETYPE_ANY ;
    lpLocalName := PChar(MapDrive);
    lpRemoteName:= PChar(UNCPath);
    lpProvider  := 'NetWare- or compatible network';
  end;
  Result := WNetAddConnection2(NwR, PChar(PassWord), PChar(UserName), 0);
end;

Other Threads