Send - Messenger Service Pair

Environment: Windows NT 4 SP3, Visual C++ 6

The "Send"-"Messenger" pair are ment to replace the old "Net send"-"Messenger". Actually I decided to try this because I was getting annoyed with the same message boxes on the screen, and since I couldn't find any information about the old stuff, I made a new pair. The "send" part does very little.It's a Win32 console app that connects to a named pipe and writes to it. The service is also a Win32 console app (Microsoft advices, isn't it) that creates a icon in the TrayIcon, and a named pipe. When the pipe receives something, the icon changes from yellow to red. The icon tip shows the number of new/total messages received. Left click on the icon shows a window with the messages, right click on it displays a context menu with the "Close" command, to stop the service.

The "send" can be used like this: "send list" to list all the computers in the network (I used Naveen Kohli class to get the names, thanks a lot), or "send <computer> message".

The service can be installed/removed from the prompt: "service -install" , "service -remove", and started from the control panel (the "Services" icon). I used Craig Link's example found in MSDN November 1998, but I changed it to suit my needs. I will comment the code in the the ServiceStart function, because the rest of the service's functions (service_ctrl, service_main etc.) are classics.

The function creates first a thread that is responsible for the icon's parent, a simple dialogbox. To hide the dialog:

   SetWindowPos(hwndDlg,NULL,-10,-10,0,0,SWP_NOZORDER|SWP_NOMOVE);

and of course the trick with the invisible modless parent to prevent from appearing in the task bar (this one also not visible - from the resources):

   HWND hwnd=CreateDialog(NULL,MAKEINTRESOURCE(IDD_DIALOG1),NULL,NULL);

The dialog's DialogProc has nothing special. On WM_INITDIALOG it displays the icon, on WM_ICON_NOTIFY - LBUTTON it creates a frame with an edit in it, on WM_ICON_NOTIFY - RBUTTON shows a context menu, WM_COMMAND - ID_POPUP_CLOSE stops the service, and WM_CLEARALL and WM_CLOSEFRAME are messages sent by the frame. Every message handling takes care of the icon also, by changing the icon or the tip.

After creating the thread, the StartService creates a named pipe, and two events - one to take care of the stop service command and one for the overlapped i/o. After reading from the pipe, it adds the text read to a buffer and, if the frame is on, it displays the new message and drops the connection. Right click on the edit clears the text and resets the icon's counters.

Downloads

Download service project -44 Kb
Download send project -16 Kb
Download exes - 12 Kb


Comments

  • about messenger( exaxt title is not available)

    Posted by Legacy on 10/25/2001 12:00am

    Originally posted by: rosireddy

    respected sir

    u didn't give full explanation there. i want detailed explanation procedure if its available in this web page. iam thinking of i didn't find the ferpect place in ur web. so kindly help in this regard.

    rose

    Reply
  • Error MessengerBruno

    Posted by Legacy on 02/21/2000 12:00am

    Originally posted by: abdij

    Hi,
    There was error "Connecting to Pipe" when i and my friend tried to communicate. Both have installed the Server and started it. Infact when he sent it i recieved it too. But after i read the message and triend send again the error message popped. It is not going.

    Bye
    Abdij

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

Top White Papers and Webcasts

  • A majority of organizations are operating under the assumption that their network has already been compromised, or will be, according to a survey conducted by the SANS Institute. With many high profile breaches in 2013 occurring on endpoints, interest in improving endpoint security is top-of-mind for many information security professionals. The full results of the inaugural SANS Endpoint Security Survey are summarized in this white paper to help information security professionals track trends in endpoint …

  • Live Event Date: September 10, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild". This loop of continuous delivery and continuous feedback is …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds