When Windows is turned off, the computer will often prompt which computers are connected to your computer, so how to know through the program
Which computers are connected to their own computers?
Bbkxjy, time: 20:23:57, ID: 549334
I have answered similar questions before, and I can cheat points again this time ,;)
Const
Maxnetarrayitems = 512;
Type
Tsessioninfo50 = packed record
Sesi50_cname: pchar; // remote computer name (connection ID in Netware)
Sesi50_username: pchar;
Sesi50_key: DWORD; // used to delete SESSION (not used in Netware)
Sesi50_num_conns: word;
Sesi50_num_opens: word; // not available in NetWare
Sesi50_time: DWORD;
Sesi50_idle_time: DWORD; // not available in NetWare
Sesi50_protocol: Char;
PADL: Char;
End;
Tnetsessionenum = function (const pszserver: pchar; slevel: smallint;
Pbbuffer: pointer; cbbuffer: word; var pcentriesread: word;
VaR pctotalavail: Word): DWORD; stdcall;
Procedure getnetsessions (computernames: tstrings );
VaR
Sessioninfo: array [0 .. maxnetarrayitems] of tsessioninfo50;
Entriesread, totalavail: word;
I: integer;
STR: string;
Netsessionenum: tnetsessionenum;
Libhandle: thandle;
Begin
Computernames. Clear;
Libhandle: = loadlibrary ('svrapi. dll ');
If libhandle <> 0 then
Begin
Try
@ Netsessionenum: = getprocaddress (libhandle, 'netsessionenum ');
If (@ netsessionenum <> nil) then
If netsessionenum (nil, 50, @ sessioninfo, sizeof (sessioninfo), entriesread, totalavail) = 0 then
Begin
For I: = 0 to entriesread-1 do
With sessioninfo [I] Do
Begin
Setstring (STR, sesi50_cname, strlen (sesi50_cname ));
Computernames. Add (STR );
End;
End;
Finally
Freelibrary (libhandle );
End;
End;
End;
The connected computer name is stored in computernames and can be used in Win9x.