Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WNetOpenEnum
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00185007
Message ID:
00187002
Views:
65
>IF WNetOpenEnum(dwScope, dwType, dwUsage, 0, @hEnum) = 0
> * it opened the enum; retrieve with WNetEnumResource
> nCount = 0xFFFFFFFF
> cBuffer = REPL(CHR(0),512)
> nBufSize = 512
> nResult = WNetEnumResource(@hEnum, @nCount, @cBuffer, @nBufSize)
> * do something with the returned NETRESOURCEs in cBuffer
>ENDIF
>
>
>You can construct a NETRESOURCE in a string; anything pointed to by the NETRESOURCE will need to be constructed off the heap, and deallocated from there. Later, you'll retrieve things from WNetEnumResource in a string buffer allocated and passed by reference; you can retrieve the things referenced by embedded pointers in a NETRESOURCE using the GetMem() and GetMemString() functions after decoding the embedded pointers into numbers using DWORDToNum(). Use the value returned in hEnum from WNetOpenEnum as the hEnum argument to WNetEnumResource(), and pass it by ref when you call WNetEnumResource, so it gets properly molested to point to the next group of things to enum.

I managed to get the information I needed by using oHeap.Alloc() to allocate a block and passed it as hEnum in both calls. cBuffer came back as a string with some info attached on the end depending on what dwType was passed. I broke down the rest of the string in 4 byte chunks to try to extract some pointers to additional network info but only found a series of meaningless textstrings like "Microsoft Network" at several addresses in a row or .NULL.. So I accomplished my task by using dwType 2 (LANmachines) then dwType 5 (current connections). It made for a nice little form to list resources, add and delete LAN connections etc. without leaving FoxPro.

I still can't get past the data type error when trying to pass a pointer to memory in Fox for the LPNETRESOURCE parameter. I've tried passing just a pointer to a block of memory, a pointer to a string, etc. I know it expects to see a specific type of structure but I can't figure out how to simulate it. I got around it in WNETOPENENUM by just passing 0.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform