>>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.
As a general rule, if you have a number that's a pointer, declare the parameter LPNETRESOURCE as INTEGER, and pass the pointer in for the argument. If you've constructed a structure in a VFP memory variable, declare it as type STRING @, and pass the string as the argument.
hEnum is declarted as INTEGER @ in WNetOpenEnum, and a numeric variable should be passed by reference in the call to WNetOpenEnum to retrieve the assigned handle. You can then use the returned value for hEnum to WNetEnumResource, passing again by reference in the call to WNetEnumResource, so that you get back the adjusted handle after each WNBetEnumResource call
Take a look at the example I did a few days ago for declarations and passing mechanisms.
Under VFP6, you may just want to rely on the new ANETRESOURCES() function.
Ed