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

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

  • Today's agile organizations pose operations teams with a tremendous challenge: to deploy new releases to production immediately after development and testing is completed. To ensure that applications are deployed successfully, an automatic and transparent process is required. We refer to this process as Zero Touch Deployment™. This white paper reviews two approaches to Zero Touch Deployment--a script-based solution and a release automation platform. The article discusses how each can solve the key …

Most Popular Programming Stories

More for Developers

RSS Feeds