Board index » delphi » WNetAddConnection2 remapping?

WNetAddConnection2 remapping?

I am having problems using WNetAddConnection2 to map an existing drive.
If I use explorer to disconnect the drive I can remap another with out any
problems.  I have tried using the WNetCancelConnection2 command and it
breaks the network connection but the mapping remains and I can not change
the mapping.  What I am trying to do is write a program to check the drive
space of all our servers and I believe I need a drive mapping to use
DiskSpace and DiskFree.  So, in order to do this I have to remap a local
drive many times.  Thanks for any help or let me know if I am doing this
all wrong.  This is going to run on a Win95 box or maybe an NT4.0 box.

James

Quote
>>>--FSU-->

 

Re:WNetAddConnection2 remapping?


James,

I don't know if this is going to help, but...

I found that it sometimes takes a little time to cancel the
connection, so you might try:

var
 Success: integer;
begin
 repeat
  Success := WNetCancelConnection2(PChar(Drive), 0, False);
 until Success = NO_ERROR;

--
Stephen Brown

Quote
James Naus wrote in message <73f5v6$le...@news.fsu.edu>...

>I am having problems using WNetAddConnection2 to map an existing
drive.
>If I use explorer to disconnect the drive I can remap another with
out any
>problems.  I have tried using the WNetCancelConnection2 command and
it
>breaks the network connection but the mapping remains and I can not
change
>the mapping.  What I am trying to do is write a program to check the
drive
>space of all our servers and I believe I need a drive mapping to use
>DiskSpace and DiskFree.  So, in order to do this I have to remap a
local
>drive many times.  Thanks for any help or let me know if I am doing
this
>all wrong.  This is going to run on a Win95 box or maybe an NT4.0

box.

Re:WNetAddConnection2 remapping?


The drive connection is getting canceled but it is still mapped.  So, I
can't use the same drive letter over again.  Is there some sort of unmap
command.  Thanks.

James

Quote
Stephen Brown (sbr...@sprocket.win-uk.net) wrote:

: James,
:
: I don't know if this is going to help, but...
:
: I found that it sometimes takes a little time to cancel the
: connection, so you might try:
:
: var
:  Success: integer;
: begin
:  repeat
:   Success := WNetCancelConnection2(PChar(Drive), 0, False);
:  until Success = NO_ERROR;
:
: --
: Stephen Brown
:
Quote
: James Naus wrote in message <73f5v6$le...@news.fsu.edu>...

: >
: >I am having problems using WNetAddConnection2 to map an existing
: drive.
: >If I use explorer to disconnect the drive I can remap another with
: out any
: >problems.  I have tried using the WNetCancelConnection2 command and
: it
: >breaks the network connection but the mapping remains and I can not
: change
: >the mapping.  What I am trying to do is write a program to check the
: drive
: >space of all our servers and I believe I need a drive mapping to use
: >DiskSpace and DiskFree.  So, in order to do this I have to remap a
: local
: >drive many times.  Thanks for any help or let me know if I am doing
: this
: >all wrong.  This is going to run on a Win95 box or maybe an NT4.0
: box.
:
:
:

--
---------------========================================================
------------==========          |    n...@cs.fsu.edu
----------===========   James   |    n...@freenet.fsu.edu
----------===========           |--------------------------------------
----------===========   Naus    |    Florida State University
------------==========          |    Tallahassee, Florida USA
---------------========================================================

Re:WNetAddConnection2 remapping?


Sorry to follow my own post but I have more info.  The error that I get is
ERROR_DEVICE_ALREADY_REMEMBERED.  How do I "unremember" it.  Thanks.

: The drive connection is getting canceled but it is still mapped.  So, I
: can't use the same drive letter over again.  Is there some sort of unmap
: command.  Thanks.
:
: James
:
:
:
:
: Stephen Brown (sbr...@sprocket.win-uk.net) wrote:
: : James,
: :
: : I don't know if this is going to help, but...
: :
: : I found that it sometimes takes a little time to cancel the
: : connection, so you might try:
: :
: : var
: :  Success: integer;
: : begin
: :  repeat
: :   Success := WNetCancelConnection2(PChar(Drive), 0, False);
: :  until Success = NO_ERROR;
: :
: : --
: : Stephen Brown
: :
: : James Naus wrote in message <73f5v6$le...@news.fsu.edu>...
: : >
: : >I am having problems using WNetAddConnection2 to map an existing
: : drive.
: : >If I use explorer to disconnect the drive I can remap another with
: : out any
: : >problems.  I have tried using the WNetCancelConnection2 command and
: : it
: : >breaks the network connection but the mapping remains and I can not
: : change
: : >the mapping.  What I am trying to do is write a program to check the
: : drive
: : >space of all our servers and I believe I need a drive mapping to use
: : >DiskSpace and DiskFree.  So, in order to do this I have to remap a
: : local
: : >drive many times.  Thanks for any help or let me know if I am doing
: : this
: : >all wrong.  This is going to run on a Win95 box or maybe an NT4.0
: : box.
: :
: :
: :
:
: --
: ---------------========================================================
: ------------==========          |    n...@cs.fsu.edu
: ----------===========   James   |    n...@freenet.fsu.edu
: ----------===========           |--------------------------------------
: ----------===========   Naus    |    Florida State University
: ------------==========          |    Tallahassee, Florida USA
: ---------------========================================================

--
---------------========================================================
------------==========          |    n...@cs.fsu.edu
----------===========   James   |    n...@freenet.fsu.edu
----------===========           |--------------------------------------
----------===========   Naus    |    Florida State University
------------==========          |    Tallahassee, Florida USA
---------------========================================================

Re:WNetAddConnection2 remapping?


Hi James,

Well, the error is reporting exactly what you are seeing: the drive
letter is still assigned to the network connection, even though the
connection itself has been closed.

Are you passing the CONNECT_UPDATE_PROFILE flag when you call
WNetAddConnection? As I understand it, this causes the mapping to be
'remembered'. Try 0 instead.

Alternatively, try passing that same flag when you cancel the
connection. That might cause it to be 'unremembered'

--
Stephen Brown

Quote
James Naus wrote in message <73hkiv$rr...@news.fsu.edu>...

>Sorry to follow my own post but I have more info.  The error that I
get is
>ERROR_DEVICE_ALREADY_REMEMBERED.  How do I "unremember" it.  Thanks.

>: The drive connection is getting canceled but it is still mapped.
So, I
>: can't use the same drive letter over again.  Is there some sort of
unmap
>: command.  Thanks.

Other Threads