Getting the list of shares connected to a machine

445 Views Asked by At

Consider that i have connected to multiple shares of a remote machine( \\machineA\share1, \\machineA\share2....) along with shares on other remote machines.

Now my question is how to find only those shares which are connected to a particular machine. For eg, only those shares which are connected to machineA.

I already came across WNetOpenEnum and WNetEnumResource. But these are highly inefficient that they will return all shares which are connected to my machine and then i will have to search through the results for the shares connected to machineA:(

I need to know if there is some other function, using which i can find the share.

I am working on VC++ 6.0.

edit: Hey guys having another trouble. Whenever i try to connect to a share on the machine i get the following error: "The referenced account is currently locked out and may not be logged on to" Has anyone encountered this problem and how was it solved

3

There are 3 best solutions below

1
Piskvor left the building On

Iterating through all shares and only picking the ones you want, to me, looks as efficient as it gets. Is there some circumstance why you can't do it? (except laziness ;))

0
tsilb On
foreach (string systemName in systemNames)
 System.IO.Directory.GetDirectories("\\"+systemName+"\");
1
tsilb On

To resolve your lockout problem, log onto a the target server (Or, if it's on a domain, log onto any domain controller on that domain), go to Control Panel > Administrative Tools > Active Directory Users & Computers, navigate to the User you're logging in as, and unlock it.

If the system is not on a domain, simply log onto it and unlock the account via the "Local users & Groups" tool in compmgmt.msc.