473,410 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

GetLogicalDrives doesn't retrieve remote drives on Windows Vista

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
9 8525
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
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
>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
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
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
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
>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
>>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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lastusernameleft | last post by:
Is there a .NET method for doing this? I haven't found anything else that works. Thanks
3
by: Dean Slindee | last post by:
Once you've gotten a list of logical drives with Directory.GetLogicalDrives, how would you get the name associated with that drive? Thanks, Dean Slindee
0
by: Daniel | last post by:
Hi groups, me again! Is there a way to force the FolderBrowser control to display all the physical drives (not shares) on a remote machine? For example, I have a machine called ABC that has...
2
by: Daniel | last post by:
Any ideas why the below function does not work? It just returns the drives of the local computer not the remote one. I don't think it is permissions because I am in the Admins group on the remote...
23
by: wylbur37 | last post by:
I'm running an Apache server on my own computer (Windows XP Pro). I wrote a simple PHP script (called test3.php) that I'm running by putting the following URL in the address bar of the browser...
0
by: rmckbrown | last post by:
Using .Net FW 1.1 and VB.net I am calling system.io.directory.getlogicaldrives from a windows service; however, only the local drives are returned, and not my mapped drives. When I execute the...
15
by: =?Utf-8?B?TVNU?= | last post by:
To demonstrate my problem, I have a very simple VB Windows application. It has a text box that is used to display a counter, a button to reset the counter, and a timer that increments the counter...
4
by: Ryderch | last post by:
Greetings folks! I need to open a file located on a remote machine running DOS (ouch!) from a client running Vista. The network connection is based on NetBEUI. Test1 Code running on the...
4
by: Kerem Gümrükcü | last post by:
Hi, is it possible to get the Information that comes from OperatingSystem Class from a Remote Comupter. Is there a remote information supporting OperatingSystem Class or can i get this...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.