Adding Active Friends Lists to your Programs


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

Environment:VC5, VC6

Many programs today suffer from the fact that their users have to connect using IP addresses. This is impossible for dialup users, whose IPs change all the time, and painful for LAN users who don't know their IP addresses or whose addresses also change. In addition, many collaborative programs could benefit from offering friends lists, showing friends as online or offline, providing status information. This kind of functionality is hard to provide, requiring a dedicated Internet database and a new client - client protocol. But it is offered today through a system called AwareNet, which is offered free of charge and royalty.

Above is a screenshot of the example program which comes with the AwareNet SDK. To track IPs, get friends' status information, and display the above dialog box only required 270 lines of code. Read further to learn how to use the AwareNet SDK, how to add friend information to your programs.

Step 1: Set up your compile environment

AwareNet comes as a DLL, so you'll need to statically link your project to the associated LIB file, provided with the SDK. Also make sure you copy the AwareNet.dll file into your program's directory, and when you distribute your program, make sure AwareNet is included. You may need to refer to your compiler's documentation regarding the procedure for adding a LIB file to the link phase.

Step 2: Add AwareNet initialization to your code

CAwareNet AwareNet;
AwareNet->Initialize(this->m_hWnd, EXAMPLEPW_SERVICE);

The above code shows the initialization procedure. You must create an instance of the CAwareNet class, and call its Initialize member function, before using any of its other member functions.

Step 3: Catch signals

AwareNet sends a registered Windows message whenever a friend goes online or offline. You can catch it in the following way.


The AwareNet_UpdateContactsMsg UINT is exported by AwareNet.dll. Your OnUpdateFriendsList function should do whatever is appropriate when the friends list changes.

Step 4: Exercise AwareNet

Now you can use AwareNet's core functionality. Here are some of the commands:



Using these, you can add and remove friends from AwareNet, find out if they are online, lookup their IP addresses and profile information (which includes the person's name and e-mail address). All person-finding is done by e-mail, ensuring an understandable interface for both programmer and user.

Here is some source code from ExamplePW, the PeopleWatcher example program which ships with the AwareNet SDK:

void CExamplePWDlg::RefreshFriendsList()
   CListCtrl *ListCtrl;
   int Frnd = -1, Me;
   PersonalInfo PInfo;
   int i, newindex;

/*********************** AWARENET ***********************/
/* Loops over the friend list to add each friend to the
   friend list control.                                 */

   ListCtrl = (CListCtrl *)GetDlgItem(IDC_FRIENDLIST);

   if(!AwareNet || !ListCtrl)

   /* My ID number is saved in the integer Me */
   Me = AwareNet->GetMyID();

   /* Clear out the old information */

   /* Loop over the friends list */
   for(i = 0; (Frnd = AwareNet->GetFriend(i)) >= 0; i++)
      /* If the one we're looking at is us, we just continue;
         you don't want to see yourself on your friends list even
         though, internally, your information is stored in the
         friends list */

      if(Frnd == Me)

      /* For the friend who is not me, I extract the profile
         information */
      AwareNet->GetProfile(Frnd, &PInfo);

      /* If he's online, I show him with a green dot.  If not,
         with a red dot.  Offline friends are further down
         in the list to make reading easier */

      if(AwareNet->IsOnline(Frnd, EXAMPLEPW_SERVICE, true))
         newindex = ListCtrl->InsertItem(0, PInfo.Name, 0);
         newindex = ListCtrl->InsertItem(i, PInfo.Name, 1);

      /* Store his ID number with his entry in the list control
         so we can extract it later in case we want to delete him. */
      ListCtrl->SetItemData(newindex, (DWORD)Frnd);

   /* If we actually added someone, select the first one */
   if(i > 1)
      SelectListItem(ListCtrl, 0);


This code simply displays the list of online and offline friends.

Step 5: More details

This is really all you need to know to create an AwareNet application. If you want more information on how the system works, how it's supported, and what the licensing policy is, you are encouraged to visit its parent company's web site. Contained within are all necessary documents, and the SDK itself for download.


Download demo project - 409 Kb

Download the SDK - 528 Kb
Note that this link will take you to an external site.



  • Can not run the sample

    Posted by Legacy on 09/14/1999 07:00am

    Originally posted by: Tn

    Could you please tell me how I can run this sample demo. I got the error which said: "Can not find Awarenet library" eventhough it is compiled successfully.

    I tried to put the dll in the path as well as in the current working directory but it did not work.

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date