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

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • Hundreds of millions of users have adopted public cloud storage solutions to satisfy their Private Online File Sharing and Collaboration (OFS) needs. With new headlines on cloud privacy issues appearing almost daily, the need to explore private alternatives has never been stronger. Join ESG Senior Analyst Terri McClure and Connected Data in this on-demand webinar to take a look at the business drivers behind OFS adoption, how organizations can benefit from on-premise deployments, and emerging private OFS …

Most Popular Programming Stories

More for Developers

RSS Feeds