Jump to content

Using WNetUseConnection and WNetCancelConnection2

- - - - -

  • Please log in to reply
No replies to this topic

#1
darrylP

darrylP

    Newbie

  • Members
  • Pip
  • 1 posts
Hi, I have created an app that allows users to map network drives and disconnect them. Everytihng is working perfectly except for one strange side effect. Example:

I want to give the user the option to map a network drive to an existing drive (ie a drive that already has another network share attached to it). So lets say the user currently has their S: drive mapped to \\server1\data and they want to connect S: to \\server2\info. This involves calling WNetCancelConnection2 to first disconnect the existing share, and then WNetUseConnection to connect the new share. This all works as expected, however when I open My computer I notice that S: still says data on server1 (S:) however when I double click on S: it is actually pointing to the correct share which is \\server2\info, its just that it has not updated it to display the correct path in my computer or windows explorer.

Now if I do it in 2 seperate steps, ie have the user disconnect the drive first, then connect it to the new location it updates correctly. Very weird. I have tried putting in a small delay, even a large delay but it doesn't make a difference? Any suggestions? I notice that when you map a network drive in Windows Explorer it does not let you replace an existing drive in one go, you need to do it seperately, does anyone know why this is so?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users