How to use a program to know which computers are connected to their own computers

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.