Для себя я использовал код где-то нарытый в своё время:
- #include "stdafx.h"
- #include <windows.h>
- #include <winnetwk.h>
-
- BOOL GetListNet(LPNETRESOURCE lpNet1)
- {
- LPNETRESOURCE lpNet2;
- HANDLE hEnum;
- DWORD buff = 16384;
- DWORD cnt = -1;
- DWORD dwResult;
-
- dwResult = WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0, lpNet1, &hEnum);
-
- if(dwResult == NO_ERROR)
- {
- lpNet2 = (LPNETRESOURCE) GlobalAlloc(GPTR, buff);
- if(lpNet2 == NULL)
- return FALSE;
-
- do
- {
- ZeroMemory(lpNet2, buff);
-
- dwResult = WNetEnumResource(hEnum, &cnt, lpNet2, &buff);
-
- if(dwResult == NO_ERROR)
- {
-
- for(DWORD i = 0; i < cnt; i++)
- {
- MessageBox(NULL, lpNet2.lpRemoteName, "Message", MB_OK);
-
- if(RESOURCEUSAGE_CONTAINER == (lpNet2.dwUsage & RESOURCEUSAGE_CONTAINER))
- {
- if(!GetListNet(&lpNet2))
- {
- MessageBox(NULL, "GetListNet return FALSE;", "Message", MB_OK);
- }
- }
- }
-
- }
- else return FALSE;
- }
- while (dwResult != ERROR_NO_MORE_ITEMS);
-
- if(WNetCloseEnum(hEnum) != NO_ERROR)
- return FALSE;
-
- }
- else return FALSE;
-
- return TRUE;
- }
-
- int _tmain(int argc, _TCHAR* argv[])
- {
- LPNETRESOURCE lpRun;
- DWORD buff = 16384;
-
- lpRun = (LPNETRESOURCE) GlobalAlloc(GPTR, buff);
-
- GetListNet(lpRun);
-
- return 0;
- }
Вот ещё откопал исходник http://slil.ru/27820432
Ответить
|