1. How to activate the current screen saver
/ / Activate the current screen saver, Jingzhou Xu
Postmessage (WM_SYSCOMMAND, SC_SCREENSAVE, 0);
2. How to get a local area online computer name and their IP addresses
l Connect WS2_32.LIB and MPR.LIB libraries
l #include winsock2.h
CString Strtemp;
Struct Hostent * Host;
Struct in_addr * ptr; // Retrieve IP Address
DWORD DWSCOPE = Resource_Context;
NetResource * NetResource = NULL;
Handle Henum;
WNETOpenenum (DWSCope, Null, NULL,
NULL, & Henum
Wsadata wsadata;
WSASTARTUP (Makeword (1, 1), & WSADATA);
IF (henum)
{
DWORD count = 0xfffffffff;
DWORD BUFFERSIZE = 2048;
LPVOID BUFFER = New Char [2048];
WneetenumResource (Henum, & Count,
Buffer, & buffersize;
NetResource = (NetResource *) Buffer;
Char szhostname [200];
Unsigned Int i;
For (i = 0;
i i , NetResource ) { IF (NetResource-> dwusage == Resourceusage_Container && NetResource-> DWTYPE == Resourcetype_any { IF (NetResource-> LPREMOTENAME) { CString strfullname = NetResource-> LPREMOTENAME; IF (0 == Strfullname.Left (2) .compare ("")) Strfullname = Strfullname.right Strfullname.getLength () - 2); Gethostname (szhostname, Strlen (szhostname); Host = gethostbyname (strfullname); IF (Host == NULL) Continue; PTR = (struct in_addr *) Host-> h_addr_list [0]; // =. Separate IP: 211.40.35.76. INT A = PTR-> S_un.s_un_b.s_b1; // 211 INT B = Ptr-> S_un.s_un_b.s_b2; // 40 INT C = PTR-> S_un.s_un_b.s_b3; // 35 INT D = PTR-> S_un.s_un_b.s_b4; // 76 Strtemp.Format ("% s ->% D.% d.% d.% d", StrfullName, A, B, C, D); AfxMessageBox (Strtemp); } } } DELETE BUFFER; WNETCloseenum (Henum); } WSACLEANUP (); Contact information: Email: jingzhou_xu@163.com Future Studio (Future Studio)