🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #1944

Network share mapping sequence fails on Vista

#1944
From: Kris
Date: Sat, 09 Jun 2007 14:29
37 lines
2505 bytes
Hi,

I've written an application that maps several network shares to drive 
letters. To accomplish this I repeat the sequence below for every share 
that needs to be mapped (typically 3 to 4 shares):
- WNetCancelConnection2() - remove any previous mapping that might exist
- WNetAddConnection3() - create a new mapping

This is pretty straightforward and works great on all operating systems 
except, strangely enough, Vista. For some reason, after executing the 
above sequence several times (once for each share), the mapped 
connections regularly do not become visible as drive letters. Only after 
a reboot they show up. And, even though the mappings clearly went wrong, 
no error is returned by any of the WNetxxx-calls I made.

Furthermore, if you use WNetGetUniversalName() to query the UNC of those 
badly mapped drive letters you won't get a network path back (which is 
consistent with the mappings being absent in My Computer). However, if 
you use WNetEnumResource() to enumerate RESOURCE_REMEMBERED items you do 
get back the UNC that is assigned to the drive letter even though it 
does not show up in My Computer. So, the mapping is there (as confirmed 
after a reboot) but initially does not show up in My Computer.

I believe I managed to work around the problem by slowing down the 
sequence of  disconnecting/connecting drive letters; After 
WNetCancelConnection2() I suspend everything by using Sleep(100). The 
same is done after the WNetAddConnection3().

Even though this apparently contained the problem I am still a bit 
worried about this solution since I don't know the root-cause of the 
problem.

Any insight on this problem is very much appreciated.

Thanks.

Kris
Technical Details
Message-ID: <466ab959@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,39c1996646897986,start
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Sat, 09 Jun 2007 16:29:49 +0200
From: Kris <ks@ks.com>
User-Agent: Thunderbird 2.0.0.0 (Windows/20070326)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Network share mapping sequence fails on Vista
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 83.134.80.130
Message-ID: <466ab959@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1181399385 83.134.80.130 (9 Jun 2007 07:29:45 -0700)
Lines: 37
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail