I am running three computers in my home network, all within the same workgroup. Now I want to find out on my computer which volumes are present/mounted on the other computers im my network, and I want to do it in my C++/C# code.
Method NetServerEnum works fine and delivers the computer names in my network but now I am stuck and cannot identify a function which lists the volumes of such named 'remote' computer. I have already tried function NetServerDiskEnum but receive ERROR_ACCESS_DENIED. Is there another function that does the trick? (Any File dialog can do it but I need to include that into my code - and without an operator intervention.
Does anybody have a hint for me?
Update (2021-04-08) Thanks to Alan, he gave me a lot to try out. I decided to proceed with using WNetEnumResource which does not require any elevated privileges. Here is my code:
#include <windows.h>
int main ( int nArgc, char** lppszArgv )
{
DWORD ErrCode;
HANDLE hEnum;
DWORD dwCount;
DWORD BfSize = 0x1000;
ErrCode = WNetOpenEnum ( RESOURCE_CONTEXT, RESOURCETYPE_ANY, RESOURCEUSAGE_ALL, NULL, &hEnum );
if ( ErrCode == NO_ERROR )
{
BYTE ucBuffer[0x1000];
NETRESOURCE* lpNr = (NETRESOURCE*)ucBuffer;
do
{
dwCount = 1;
ErrCode = WNetEnumResource ( hEnum, &dwCount, ucBuffer, (LPDWORD)&BfSize );
}
while ( ErrCode == NO_ERROR && dwCount == 1 );
ErrCode = WNetCloseEnum ( hEnum );
}
return 0;
}
That code gives me a perfect list of all computers in my home network. Now I try to figure out how to obtain the names of volumes and/or directories that current user has access to. It might take me a while, I come back with more results.