I know GetDriveType() worked in XP for remote drives.
So I guess I'll have to just forget about GetDriveType() and just try
WNetGetConnection without caring about the drive type?
The problem that GetDriveType() returns DRIVE_NO_ROOT_DIR for network
mapped drives when the process is elevated results from UAC in Windows
Vista. Here is a relevant KB ariticle:
After you turn on User Account Control in Windows Vista, programs may be
unable to access some network locations
http://support.microsoft.com/kb/937624
When UAC is enabled, administrators without elevation and administrators
with elevation are treated as different users. If the network mapped drives
were created by an admin without elevation, only that admin (without
elevation) can use the mapped drive and get the right drive type from
GetDriveType. This explains why GetDriveType returns DRIVE_NO_ROOT_DIR when
the application is elevated.
There are basically two solutions
1. Configure the EnableLinkedConnections registry value (recommended)
To resolve this problem, configure the EnableLinkedConnections registry
value. This value enables Windows Vista to share network connections
between the filtered access token and the full administrator access token
for a member of the Administrators group. After you configure this registry
value, LSA checks whether there is another access token that is associated
with the current user session if a network resource is mapped to an access
token. If LSA determines that there is a linked access token, it adds the
network share to the linked location. For more info, please refer to the
above KB article.
2. Use WNetGetConnection as you did.
If the process is not elevated, WNetGetConnection returns 0 (NO_ERROR) as
expected.
If the process is elevated, WNetGetConnection returns
ERROR_CONNECTION_UNAVAIL, which means that the device is not currently
connected, but it is a persistent connection. The function fails with
ERROR_NOT_CONNECTED or ERROR_CONNECTION_UNAVAIL. This is because a
connection made using Microsoft LAN Manager is visible only to applications
running in the same logon session as the application that made the
connection.
Regards,
Jialiang Ge (jia...@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
MSDN Managed Newsgroup support offering is for non-urgent issues where an
initial response from the community or a Microsoft Support Engineer within
2 business day is acceptable. Please note that each follow up response may
take approximately 2 business days as the support professional working with
you may need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
I thought my mapped drives were working under that profile -- but it was
Murphy -- the only mapped drive I tried happened to be the only one that
worked (I must have mapped it at some point?)
Anyway Thanks...
I usually do TIA so I don't have to send a thanks message - but I guess it's
your policy to get one to close the tread.
""Jialiang Ge [MSFT]"" <jia...@online.microsoft.com> wrote in message
news:6zoQyFFg...@TK2MSFTNGHUB02.phx.gbl...
Regards,
Jialiang Ge (jia...@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================