aboutsummaryrefslogtreecommitdiff
path: root/CPP/Windows/Net.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CPP/Windows/Net.cpp56
1 files changed, 42 insertions, 14 deletions
diff --git a/CPP/Windows/Net.cpp b/CPP/Windows/Net.cpp
index 2a3952a..0ac82d4 100644
--- a/CPP/Windows/Net.cpp
+++ b/CPP/Windows/Net.cpp
@@ -14,13 +14,41 @@
14extern bool g_IsNT; 14extern bool g_IsNT;
15#endif 15#endif
16 16
17extern "C"
18{
19#if !defined(WNetGetResourceParent)
20// #if defined(Z7_OLD_WIN_SDK)
21// #if (WINVER >= 0x0400)
22DWORD APIENTRY WNetGetResourceParentA(IN LPNETRESOURCEA lpNetResource,
23 OUT LPVOID lpBuffer, IN OUT LPDWORD lpcbBuffer);
24DWORD APIENTRY WNetGetResourceParentW(IN LPNETRESOURCEW lpNetResource,
25 OUT LPVOID lpBuffer, IN OUT LPDWORD lpcbBuffer);
26#ifdef UNICODE
27#define WNetGetResourceParent WNetGetResourceParentW
28#else
29#define WNetGetResourceParent WNetGetResourceParentA
30#endif
31
32DWORD APIENTRY WNetGetResourceInformationA(IN LPNETRESOURCEA lpNetResource,
33 OUT LPVOID lpBuffer, IN OUT LPDWORD lpcbBuffer, OUT LPSTR *lplpSystem);
34DWORD APIENTRY WNetGetResourceInformationW(IN LPNETRESOURCEW lpNetResource,
35 OUT LPVOID lpBuffer, IN OUT LPDWORD lpcbBuffer, OUT LPWSTR *lplpSystem);
36#ifdef UNICODE
37#define WNetGetResourceInformation WNetGetResourceInformationW
38#else
39#define WNetGetResourceInformation WNetGetResourceInformationA
40#endif
41// #endif // (WINVER >= 0x0400)
42#endif
43}
44
17namespace NWindows { 45namespace NWindows {
18namespace NNet { 46namespace NNet {
19 47
20DWORD CEnum::Open(DWORD scope, DWORD type, DWORD usage, LPNETRESOURCE netResource) 48DWORD CEnum::Open(DWORD scope, DWORD type, DWORD usage, LPNETRESOURCE netResource)
21{ 49{
22 Close(); 50 Close();
23 DWORD result = ::WNetOpenEnum(scope, type, usage, netResource, &_handle); 51 const DWORD result = ::WNetOpenEnum(scope, type, usage, netResource, &_handle);
24 _handleAllocated = (result == NO_ERROR); 52 _handleAllocated = (result == NO_ERROR);
25 return result; 53 return result;
26} 54}
@@ -29,7 +57,7 @@ DWORD CEnum::Open(DWORD scope, DWORD type, DWORD usage, LPNETRESOURCE netResourc
29DWORD CEnum::Open(DWORD scope, DWORD type, DWORD usage, LPNETRESOURCEW netResource) 57DWORD CEnum::Open(DWORD scope, DWORD type, DWORD usage, LPNETRESOURCEW netResource)
30{ 58{
31 Close(); 59 Close();
32 DWORD result = ::WNetOpenEnumW(scope, type, usage, netResource, &_handle); 60 const DWORD result = ::WNetOpenEnumW(scope, type, usage, netResource, &_handle);
33 _handleAllocated = (result == NO_ERROR); 61 _handleAllocated = (result == NO_ERROR);
34 return result; 62 return result;
35} 63}
@@ -37,7 +65,7 @@ DWORD CEnum::Open(DWORD scope, DWORD type, DWORD usage, LPNETRESOURCEW netResour
37 65
38static void SetComplexString(bool &defined, CSysString &destString, LPCTSTR srcString) 66static void SetComplexString(bool &defined, CSysString &destString, LPCTSTR srcString)
39{ 67{
40 defined = (srcString != 0); 68 defined = (srcString != NULL);
41 if (defined) 69 if (defined)
42 destString = srcString; 70 destString = srcString;
43 else 71 else
@@ -179,7 +207,7 @@ DWORD CEnum::Close()
179{ 207{
180 if (!_handleAllocated) 208 if (!_handleAllocated)
181 return NO_ERROR; 209 return NO_ERROR;
182 DWORD result = ::WNetCloseEnum(_handle); 210 const DWORD result = ::WNetCloseEnum(_handle);
183 _handleAllocated = (result != NO_ERROR); 211 _handleAllocated = (result != NO_ERROR);
184 return result; 212 return result;
185} 213}
@@ -204,7 +232,7 @@ DWORD CEnum::Next(CResource &resource)
204 ZeroMemory(lpnrLocal, kBufferSize); 232 ZeroMemory(lpnrLocal, kBufferSize);
205 DWORD bufferSize = kBufferSize; 233 DWORD bufferSize = kBufferSize;
206 DWORD numEntries = 1; 234 DWORD numEntries = 1;
207 DWORD result = Next(&numEntries, lpnrLocal, &bufferSize); 235 const DWORD result = Next(&numEntries, lpnrLocal, &bufferSize);
208 if (result != NO_ERROR) 236 if (result != NO_ERROR)
209 return result; 237 return result;
210 if (numEntries != 1) 238 if (numEntries != 1)
@@ -224,7 +252,7 @@ DWORD CEnum::Next(CResourceW &resource)
224 ZeroMemory(lpnrLocal, kBufferSize); 252 ZeroMemory(lpnrLocal, kBufferSize);
225 DWORD bufferSize = kBufferSize; 253 DWORD bufferSize = kBufferSize;
226 DWORD numEntries = 1; 254 DWORD numEntries = 1;
227 DWORD result = NextW(&numEntries, lpnrLocal, &bufferSize); 255 const DWORD result = NextW(&numEntries, lpnrLocal, &bufferSize);
228 if (result != NO_ERROR) 256 if (result != NO_ERROR)
229 return result; 257 return result;
230 if (numEntries != 1) 258 if (numEntries != 1)
@@ -233,7 +261,7 @@ DWORD CEnum::Next(CResourceW &resource)
233 return result; 261 return result;
234 } 262 }
235 CResource resourceA; 263 CResource resourceA;
236 DWORD result = Next(resourceA); 264 const DWORD result = Next(resourceA);
237 ConvertResourceToResourceW(resourceA, resource); 265 ConvertResourceToResourceW(resourceA, resource);
238 return result; 266 return result;
239} 267}
@@ -249,7 +277,7 @@ DWORD GetResourceParent(const CResource &resource, CResource &parentResource)
249 DWORD bufferSize = kBufferSize; 277 DWORD bufferSize = kBufferSize;
250 NETRESOURCE netResource; 278 NETRESOURCE netResource;
251 ConvertCResourceToNETRESOURCE(resource, netResource); 279 ConvertCResourceToNETRESOURCE(resource, netResource);
252 DWORD result = ::WNetGetResourceParent(&netResource, lpnrLocal, &bufferSize); 280 const DWORD result = ::WNetGetResourceParent(&netResource, lpnrLocal, &bufferSize);
253 if (result != NO_ERROR) 281 if (result != NO_ERROR)
254 return result; 282 return result;
255 ConvertNETRESOURCEToCResource(lpnrLocal[0], parentResource); 283 ConvertNETRESOURCEToCResource(lpnrLocal[0], parentResource);
@@ -268,7 +296,7 @@ DWORD GetResourceParent(const CResourceW &resource, CResourceW &parentResource)
268 DWORD bufferSize = kBufferSize; 296 DWORD bufferSize = kBufferSize;
269 NETRESOURCEW netResource; 297 NETRESOURCEW netResource;
270 ConvertCResourceToNETRESOURCE(resource, netResource); 298 ConvertCResourceToNETRESOURCE(resource, netResource);
271 DWORD result = ::WNetGetResourceParentW(&netResource, lpnrLocal, &bufferSize); 299 const DWORD result = ::WNetGetResourceParentW(&netResource, lpnrLocal, &bufferSize);
272 if (result != NO_ERROR) 300 if (result != NO_ERROR)
273 return result; 301 return result;
274 ConvertNETRESOURCEToCResource(lpnrLocal[0], parentResource); 302 ConvertNETRESOURCEToCResource(lpnrLocal[0], parentResource);
@@ -276,7 +304,7 @@ DWORD GetResourceParent(const CResourceW &resource, CResourceW &parentResource)
276 } 304 }
277 CResource resourceA, parentResourceA; 305 CResource resourceA, parentResourceA;
278 ConvertResourceWToResource(resource, resourceA); 306 ConvertResourceWToResource(resource, resourceA);
279 DWORD result = GetResourceParent(resourceA, parentResourceA); 307 const DWORD result = GetResourceParent(resourceA, parentResourceA);
280 ConvertResourceToResourceW(parentResourceA, parentResource); 308 ConvertResourceToResourceW(parentResourceA, parentResource);
281 return result; 309 return result;
282} 310}
@@ -293,11 +321,11 @@ DWORD GetResourceInformation(const CResource &resource,
293 NETRESOURCE netResource; 321 NETRESOURCE netResource;
294 ConvertCResourceToNETRESOURCE(resource, netResource); 322 ConvertCResourceToNETRESOURCE(resource, netResource);
295 LPTSTR lplpSystem; 323 LPTSTR lplpSystem;
296 DWORD result = ::WNetGetResourceInformation(&netResource, 324 const DWORD result = ::WNetGetResourceInformation(&netResource,
297 lpnrLocal, &bufferSize, &lplpSystem); 325 lpnrLocal, &bufferSize, &lplpSystem);
298 if (result != NO_ERROR) 326 if (result != NO_ERROR)
299 return result; 327 return result;
300 if (lplpSystem != 0) 328 if (lplpSystem != NULL)
301 systemPathPart = lplpSystem; 329 systemPathPart = lplpSystem;
302 ConvertNETRESOURCEToCResource(lpnrLocal[0], destResource); 330 ConvertNETRESOURCEToCResource(lpnrLocal[0], destResource);
303 return result; 331 return result;
@@ -317,7 +345,7 @@ DWORD GetResourceInformation(const CResourceW &resource,
317 NETRESOURCEW netResource; 345 NETRESOURCEW netResource;
318 ConvertCResourceToNETRESOURCE(resource, netResource); 346 ConvertCResourceToNETRESOURCE(resource, netResource);
319 LPWSTR lplpSystem; 347 LPWSTR lplpSystem;
320 DWORD result = ::WNetGetResourceInformationW(&netResource, 348 const DWORD result = ::WNetGetResourceInformationW(&netResource,
321 lpnrLocal, &bufferSize, &lplpSystem); 349 lpnrLocal, &bufferSize, &lplpSystem);
322 if (result != NO_ERROR) 350 if (result != NO_ERROR)
323 return result; 351 return result;
@@ -329,7 +357,7 @@ DWORD GetResourceInformation(const CResourceW &resource,
329 CResource resourceA, destResourceA; 357 CResource resourceA, destResourceA;
330 ConvertResourceWToResource(resource, resourceA); 358 ConvertResourceWToResource(resource, resourceA);
331 AString systemPathPartA; 359 AString systemPathPartA;
332 DWORD result = GetResourceInformation(resourceA, destResourceA, systemPathPartA); 360 const DWORD result = GetResourceInformation(resourceA, destResourceA, systemPathPartA);
333 ConvertResourceToResourceW(destResourceA, destResource); 361 ConvertResourceToResourceW(destResourceA, destResource);
334 systemPathPart = GetUnicodeString(systemPathPartA); 362 systemPathPart = GetUnicodeString(systemPathPartA);
335 return result; 363 return result;