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

  • Following an IT incident through to resolution is more than just acknowledging an alert and restarting a server. The recent State of On-Call Report found that it takes most companies an average of 10-30 minutes to resolve an incident with an average of 5 people involved. Imagine how much money and time companies are spending to deal with incident resolution. But what if you had a tool that offered solutions baked in? Or a tool that sent alerts to the right person or team every time? These are the kind of …

  • How to give users what they want AND maintain control, visibility, and security. File sync and share is everywhere. In the past decade, cloud-based storage and syncing solutions have exploded to fill a growing need for anytime, anywhere access to everything from photos and videos to documents, spreadsheets, and PDFs. We understand that choosing any new service or tool can be a lengthy and complex process. That's why we've created this buyer's guide to help make your evaluation process a little bit easier. In …

Most Popular Programming Stories

More for Developers

RSS Feeds

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