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: March 19, 2015 @ 1:00 p.m. ET / 10:00 a.m. PT The 2015 Enterprise Mobile Application Survey asked 250 mobility professionals what their biggest mobile challenges are, how many employees they are equipping with mobile apps, and their methods for driving value with mobility. Join Dan Woods, Editor and CTO of CITO Research, and Alan Murray, SVP of Products at Apperian, as they break down the results of this survey and discuss how enterprises are using mobile application management and private …

  • Remember getting your first box of LEGOS as a kid? How fun it was putting the pieces together, collaborating with your friends to create something new? Now, as an IT professional, assembling and maintaining a Lego-like collaboration infrastructure isn't what you signed up for. Piecing together disparate systems of record for email, web meetings and other applications is about as painful as stepping on a pile of Legos. Download the e-book to learn how implementing a collaboration system connects systems of …

Most Popular Programming Stories

More for Developers

RSS Feeds

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