1 // Windows/Net.h 2 3 #ifndef __WINDOWS_NET_H 4 #define __WINDOWS_NET_H 5 6 #include "../Common/MyString.h" 7 8 namespace NWindows { 9 namespace NNet { 10 11 struct CResourceBase 12 { 13 DWORD Scope; 14 DWORD Type; 15 DWORD DisplayType; 16 DWORD Usage; 17 bool LocalNameIsDefined; 18 bool RemoteNameIsDefined; 19 bool CommentIsDefined; 20 bool ProviderIsDefined; 21 }; 22 23 struct CResource: public CResourceBase 24 { 25 CSysString LocalName; 26 CSysString RemoteName; 27 CSysString Comment; 28 CSysString Provider; 29 }; 30 31 #ifdef _UNICODE 32 typedef CResource CResourceW; 33 #else 34 struct CResourceW: public CResourceBase 35 { 36 UString LocalName; 37 UString RemoteName; 38 UString Comment; 39 UString Provider; 40 }; 41 #endif 42 43 class CEnum 44 { 45 HANDLE _handle; 46 bool _handleAllocated; 47 DWORD Open(DWORD scope, DWORD type, DWORD usage, LPNETRESOURCE netResource); 48 DWORD Next(LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize); 49 #ifndef _UNICODE 50 DWORD Open(DWORD scope, DWORD type, DWORD usage, LPNETRESOURCEW netResource); 51 DWORD NextW(LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize); 52 #endif 53 protected: IsHandleAllocated()54 bool IsHandleAllocated() const { return _handleAllocated; } 55 public: CEnum()56 CEnum(): _handleAllocated(false) {} ~CEnum()57 ~CEnum() { Close(); } 58 DWORD Close(); 59 DWORD Open(DWORD scope, DWORD type, DWORD usage, const CResource *resource); 60 DWORD Next(CResource &resource); 61 #ifndef _UNICODE 62 DWORD Open(DWORD scope, DWORD type, DWORD usage, const CResourceW *resource); 63 DWORD Next(CResourceW &resource); 64 #endif 65 }; 66 67 DWORD GetResourceParent(const CResource &resource, CResource &parentResource); 68 #ifndef _UNICODE 69 DWORD GetResourceParent(const CResourceW &resource, CResourceW &parentResource); 70 #endif 71 72 DWORD GetResourceInformation(const CResource &resource, 73 CResource &destResource, CSysString &systemPathPart); 74 #ifndef _UNICODE 75 DWORD GetResourceInformation(const CResourceW &resource, 76 CResourceW &destResource, UString &systemPathPart); 77 #endif 78 79 DWORD AddConnection2(const CResource &resource, LPCTSTR password, LPCTSTR userName, DWORD flags); 80 #ifndef _UNICODE 81 DWORD AddConnection2(const CResourceW &resource, LPCWSTR password, LPCWSTR userName, DWORD flags); 82 #endif 83 84 }} 85 86 #endif 87