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