By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 901 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

GetLogicalDrives doesn't retrieve remote drives on Windows Vista

P: n/a
Hi,
I have a big problem with a Visual C++ 6.0 function that retrives the
logical drives and types in the local system.
This function works perfectly on Windows 98, NT, 2000, XP and 2003, but I
have tested it on Windows Vista and it doesn't retrieve remote network
drives. It must retrieve a string with the drive letters and a string with
the drive types (2=removable drive, 3=hard drive, 4=remote drive, 5=CD-ROM
drive, 6=RAM drive)
I always run this function using a Windows user in the Administrators group,
but it still fails in Windows Vista.
Do you know how to configure Windows Vista in order to get the local network
drives?
This is my code with debug message boxes:
void GetLocalDrives(CString &strDrives, CString &strTypes)
{
DWORD unitmask;
char units[27];
char types[27];
int i, n;
char unit[4];
UINT unittype;
char szMsg[80];

unitmask = GetLogicalDrives();
n = 0;
for (i = 0; i < 26; i++)
{
if (unitmask & 0x1)
{
sprintf(unit, "%c:\\", 'A' + i);
units[n] = *unit;
unittype = GetDriveType(unit);
types[n++] = '0' + unittype;
switch (unittype)
{
case DRIVE_UNKNOWN:
sprintf(szMsg, "Drive %s of unknown type", unit);
break;
case DRIVE_NO_ROOT_DIR:
sprintf(szMsg, "Drive %s is invalid", unit);
break;
case DRIVE_REMOVABLE:
sprintf(szMsg, "Drive %s is a removable drive", unit);
break;
case DRIVE_FIXED:
sprintf(szMsg, "Drive %s is a hard disk", unit);
break;
case DRIVE_REMOTE:
sprintf(szMsg, "Drive %s is a network drive", unit);
break;
case DRIVE_CDROM:
sprintf(szMsg, "Drive %s is a CD-ROM drive", unit);
break;
case DRIVE_RAMDISK:
sprintf(szMsg, "Drive %s is a RAM disk", unit);
break;
default:
sprintf(szMsg, "Drive %s has an unknown %u drive type", unit,
unittype);
}
AfxMessageBox(szMsg);
}
unitmask = unitmask >1;
}
units[n] = '\0';
types[n] = '\0';
sprintf(szMsg, "Local drives:\t%s\nTypes:\t%s\n", units, types);
AfxMessageBox(szMsg);
strDrives = units;
strTypes = types;
}

Thanks,
Luis Antonio Rosello Garcia
Pulso Informatica, S.L.
mailto:la*@pulsoinformatica.es

Apr 24 '07 #1
Share this Question
Share on Google+
9 Replies


P: n/a
I have a big problem with a Visual C++ 6.0 function that retrives the
logical drives and types in the local system.
This function works perfectly on Windows 98, NT, 2000, XP and 2003, but I
have tested it on Windows Vista and it doesn't retrieve remote network
drives.
Hi,
Try asking in the appropriate platform sdk groups. This is a C++ newsgroup,
but your problem is a platform problem, not a C++ problem. N ot that we
don't want to help, but you have better chances of finding a correct answer
in the PSDK groups.

--
Kind regards,
Bruno van Dooren MVP - VC++
http://msmvps.com/blogs/vanDooren
br**********************@hotmail.com
Apr 25 '07 #2

P: n/a
Hi Bruno,
I've just discovered that if I enable the Administrator user and run my
program using this account, then the GetLogicalDrives runs perfectly.
I don't know why my user in the Administrators group of users can't be able
to access to remote drives, but
Do you know how to get Administrator user rights in order to run my Visual
C++ installation program without problems?
Thank's,
--
Luis Antonio Rosello Garcia
Pulso Informatica, S.L.
mailto:la*@pulsoinformatica.es

"Bruno van Dooren" wrote:
I have a big problem with a Visual C++ 6.0 function that retrives the
logical drives and types in the local system.
This function works perfectly on Windows 98, NT, 2000, XP and 2003, but I
have tested it on Windows Vista and it doesn't retrieve remote network
drives.

Hi,
Try asking in the appropriate platform sdk groups. This is a C++ newsgroup,
but your problem is a platform problem, not a C++ problem. N ot that we
don't want to help, but you have better chances of finding a correct answer
in the PSDK groups.

--
Kind regards,
Bruno van Dooren MVP - VC++
http://msmvps.com/blogs/vanDooren
br**********************@hotmail.com
Apr 25 '07 #3

P: n/a
>I've just discovered that if I enable the Administrator user and run my
>program using this account, then the GetLogicalDrives runs perfectly.
I don't know why my user in the Administrators group of users can't be able
to access to remote drives
It does seem odd. Can that user see those drives with Explorer?
>Do you know how to get Administrator user rights in order to run my Visual
C++ installation program without problems?
If its an installer, it probably should be running as Administrator
already - do you not get a UAC prompt automatically when you start the
installation? What installer is it?

If you do really need admin rights, your program should have a
manifest with the following information:

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>

For more information on the subject try Googling for the terms:
requestedExecutionLevel and requireAdministrator.

Dave
Apr 25 '07 #4

P: n/a
Hi David,
I have connected the remote drives from Windows Explorer, and I can see and
I have all permissions on remote drives from Windows Explorer. Also I have
tested the NET USE command to connect them with the same results, Explorer
goes ok and GetLogicalDrives not.
The function that uses the GetLogicalDrives is inside a Windows MFC
application made by me using Visual C++ 6.0 and Microsoft Platform SDK
february 2003 (the last compatible with Visual Studio 6.0).
The user I use in order to execute my application is the administrator user
created during Windows Vista installation, that is included in the
administrators group. Also the Administrator user was disabled, and I had to
enable it and start session with this user in order to get the remote drives
returned by GetLogicalDrives.
I don't know how to apply your XML file to my Visual C++ application. I
think that you supposed that my installation program was made using Windows
Installer, Installshield or anything similar.
Thank's David
Best regards,
--
Luis Antonio Rosello Garcia
Pulso Informatica, S.L.
mailto:la*@pulsoinformatica.es

"David Lowndes" wrote:
I've just discovered that if I enable the Administrator user and run my
program using this account, then the GetLogicalDrives runs perfectly.
I don't know why my user in the Administrators group of users can't be able
to access to remote drives

It does seem odd. Can that user see those drives with Explorer?
Do you know how to get Administrator user rights in order to run my Visual
C++ installation program without problems?

If its an installer, it probably should be running as Administrator
already - do you not get a UAC prompt automatically when you start the
installation? What installer is it?

If you do really need admin rights, your program should have a
manifest with the following information:

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>

For more information on the subject try Googling for the terms:
requestedExecutionLevel and requireAdministrator.

Dave
Apr 25 '07 #5

P: n/a
Luis,

I think I can reproduce what you're seeing. I've just tried your code
on Vista and these are the results I get:

If I connect a network drive in Explorer while logged on as the normal
Administrator account (with UAC enabled) and then try your code in a
test application set to run "AsInvoker", your code sees the network
drive.

However, if I right click on the exe and choose Run As Administrator,
it doesn't report the network drive.

It's as though the elevation account doesn't inherit the drive
mapping.
>I don't know how to apply your XML file to my Visual C++ application.
Goggle for those terms I gave you.

Dave
Apr 25 '07 #6

P: n/a
Hi David,
I can't put the NxfCliente.exe.manifiest document in my installation
application as a resource and set it to run "AsInvoker", because it is a
Visual C++ 6.0 MFC .EXE application and Visual C++ 6.0 has only one resorce
file and has no run settings (except debug or release, use of MFC static or
shared, and little more).
I've created the NxfCliente.exe.manifiest document in the same directory as
my NxfCliente.exe and run it in Windows Vista, but Windows Vista still
returns only local drives, so network drives aren't returned.
Thank you.
Best regards,
--
Luis Antonio Rosello Garcia
Pulso Informatica, S.L.
mailto:la*@pulsoinformatica.es

"David Lowndes" wrote:
Luis,

I think I can reproduce what you're seeing. I've just tried your code
on Vista and these are the results I get:

If I connect a network drive in Explorer while logged on as the normal
Administrator account (with UAC enabled) and then try your code in a
test application set to run "AsInvoker", your code sees the network
drive.

However, if I right click on the exe and choose Run As Administrator,
it doesn't report the network drive.

It's as though the elevation account doesn't inherit the drive
mapping.
I don't know how to apply your XML file to my Visual C++ application.

Goggle for those terms I gave you.

Dave
May 2 '07 #7

P: n/a
>I can't put the NxfCliente.exe.manifiest document in my installation
>application as a resource and set it to run "AsInvoker", because it is a
Visual C++ 6.0 MFC .EXE application and Visual C++ 6.0 has only one resorce
file and has no run settings (except debug or release, use of MFC static or
shared, and little more).
There will be a way of doing it - but I don't off-hand know what it
is.

Dave
May 2 '07 #8

P: n/a
>>I can't put the NxfCliente.exe.manifiest document in my installation
>>application as a resource and set it to run "AsInvoker", because it is a
Visual C++ 6.0 MFC .EXE application and Visual C++ 6.0 has only one resorce
file and has no run settings (except debug or release, use of MFC static or
shared, and little more).

There will be a way of doing it - but I don't off-hand know what it
is.
For instance:

http://bobmoore.mvps.org/Win32/w32tip76.htm

Dave
May 2 '07 #9

P: n/a
Hi Dave,
I think that I will keep my install program running in Administrator user
session, because it runs ok if you start session with this user. I have now
more urgent questions because the application that my program installs uses a
lot of devices and there is no driver for Windows Vista (ticket and standard
printers, modems, visor displays, robots, scanners, card readers, etc) and
also installs Oracle 9i software and an Oracle 9i database, but Oracle 9i
Universal Installer isn't certified by Oracle and doesn't run in Windows
Vista (sometimes Oracle don't certifies a product in an operative system but
it runs, in this case it doesn't run).
Thank's a lot Dave.
Have a good day,
--
Luis Antonio Rosello Garcia
Pulso Informatica, S.L.
mailto:la*@pulsoinformatica.es

"David Lowndes" wrote:
I can't put the NxfCliente.exe.manifiest document in my installation
application as a resource and set it to run "AsInvoker", because it is a
Visual C++ 6.0 MFC .EXE application and Visual C++ 6.0 has only one resorce
file and has no run settings (except debug or release, use of MFC static or
shared, and little more).

There will be a way of doing it - but I don't off-hand know what it
is.

Dave
May 2 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.