Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   GetDriveType and DRIVE_REMOTE (https://www.delphipraxis.net/157570-getdrivetype-drive_remote.html)

user 17. Jan 2011 04:06

GetDriveType and DRIVE_REMOTE
 
I want to list all networks drives in a PC. My current code to list local drive is GetDriveType. So I look at MSDN.

From MSDN, if the return value of GetDriveType is 4, that means DRIVE_REMOTE (The drive is a remote (network) drive)

The problem is GetDriveType can not retrieve the network drive. Here my way to produce a network drive (Win 7) : Open Network, Select a shared folder and choose map network drive.. then there will be a new drive in Window Explorer.

I know there are another API to list network drive. My question is, Does GetDriveType can not detect mapped network drive? If yes, that means mapped network drive is different with remote (network) drive?

marabu 17. Jan 2011 07:45

AW: GetDriveType and DRIVE_REMOTE
 
There is nothing wrong with GetDriveType(), if you are dealing with connected network drives.
If you are looking for remembered network drives too, have a look at WNetOpenEnum().

user 17. Jan 2011 09:06

AW: GetDriveType and DRIVE_REMOTE
 
GetDriveType works fine to get the network drive in XP.

I got this link

Zitat:

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.
What is "admin without elevation" ?

FYI, my app use elevation and I uses admin account when mapping drive.

marabu 17. Jan 2011 18:37

AW: GetDriveType and DRIVE_REMOTE
 
Sorry for not noticing your mention of WIN7. My remarks were aimed at the pre-Vista world.

Zitat:

Zitat von user
What is "admin without elevation" ?

Elevation - or User Account Control - is all about privileges and is tied to processes, not users. The support engineer you are quoting just failed in rewording the referenced knowledge base article, if I am to judge, so don't bother with "admin without elevation" too long.

Better you stick to the knowlege base article. It explains quite good, why you get DRIVE_NO_ROOT_DIR instead of DRIVE_REMOTE as a result from GetDriveType(). This is what you are experiencing, I understand.


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:07 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz