About machines in the ENUM LAN

zhaozj2021-02-16  74

It's hard to finish, I plan to write a little thing I want to write for a long time. In fact, it is a chat tool in a local area. The reason is very simple: my buddies sometimes wants to ask each other, and I don't want to use Messenger (it doesn't want So from the game), so this task fell on my head, and practiced, I haven't been programmed for a long time because of the exam.

Among them, the program of the machine in the ENUM LAN is used, which can be implemented with WNETOPENENUM and WNETENUMRESOURCE, so I wrote such a thing:

Bool Clanviewer :: EnumHosts (NetResource * pnetres) {handle henum = NULL; DWORD DWRET = WNETOPENENUM (Resource_GlobalNet, ResourceType_any, 0, PNetres, & Henum); if (dwret! = no_error) Return False;

NETRESOURCE * pResBuf = new NETRESOURCE [8]; DWORD cCount, dwBuf = 8 * sizeof NETRESOURCE; cCount = (DWORD) -1; do {dwRet = WNetEnumResource (hEnum, & cCount, (LPVOID) pResBuf, & dwBuf); for (DWORD i = 0; i

IF (dwret == Error_NO_MORE_ITEMS) {// enum finished. dwret = no_error; break;} else if (dwret! = no_error) Break;} while (dwret == no_ERROR);

DELETE PRESBUF; RETURN (dwret == NO_ERROR);}

This stuff runs very well under Win2k, but I can't run it under WinXP. I will follow it. I found that ENUM in Win2K is directly obtained, but I get all my computer, but I will get first in WinXP. A stuff is "Resource Container", that is, dwusage is resourceusage_container, pay attention to the part I marked with a yellow cast: After the first recursive, WNETENUMRESOURCE is called again, but then Ccount already has it. A positive value (last call returned), so the call failed, of course, did not run.

It is easy to correctly correct the sentence to the loop. The procedure is as follows:

转载请注明原文地址:https://www.9cbs.com/read-19262.html

New Post(0)