Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Windows NT Messenger Service

Posted on 1998-04-13
21
Medium Priority
?
263 Views
Last Modified: 2013-12-03
I'm trying to create a mailslot to receive messages instead of the messenger service in Windows NT. I have created a mailslot called \mailslot\messngr. This works in Windows 95, but why doesn't it work in Windows NT? How can I make it work?

Thank you in advance.
0
Comment
Question by:baluchi
  • 9
  • 8
  • 4
21 Comments
 
LVL 11

Expert Comment

by:alexo
ID: 1412706
You have to stop or disable the existing messenger service on NT because two processes cannot simultaneously create the mailslot (there can be only one...)

0
 

Author Comment

by:baluchi
ID: 1412707
Thank you for your answer.

I have already tried that however, and it doesn't help. If I stop the messenger service, start my program instead and then issue NET SEND from another machine, the NET SEND command will only say that the alias (computer or user name) does not exist on the network. I tried adding aliases in my program, but to add an alias the messenger service must be started.

Any ideas?

0
 
LVL 11

Accepted Solution

by:
alexo earned 320 total points
ID: 1412708
You also have to create a message target name.  Use the NetMessageNameAdd() API for that (only available under NT).
Also see: http://search.dejanews.com/getdoc.xp?AN=290658281

0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 11

Expert Comment

by:alexo
ID: 1412709
Or, you can use the Netbios() API (that works on NT and 95).
See example on: http://search.dejanews.com/getdoc.xp?AN=205405373
Also see KB article Q124960.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1412710
0
 

Author Comment

by:baluchi
ID: 1412711
Thank you for your reply.

The first example would let me create an alias and send to it, but it is still the Messenger service that receives it. I would like my program to receive the message instead of the messenger service.

Then there was the NetBios sample. I'm checking it out, but I still haven't been able to make it work. It might be what I'm looking for though.
0
 

Author Comment

by:baluchi
ID: 1412712
Great!!

The NetBios sample works. It's just the ACK left. I'm not so used to programming directly in NetBios, but I will try to find out how to send the ACK. Do you have any ideas?
0
 
LVL 11

Expert Comment

by:alexo
ID: 1412713
Not at the moment.  But if you're used to direct NetBios programming, why don't you use the Netbios() function?  That's as NetBios as it gets :-)
0
 

Author Comment

by:baluchi
ID: 1412714
Ok. The problem is I'm _not_ used to NetBios, but I'm looking in to it right now. :-)

Thank you very much for your help.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1412715
Oh sorry.  3 months old daughter == sleepless nights == tired eyes.
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 8699263
I'm not able to receive the net send data thru NetBios. It is not giving any errors, but other machines can't send to thi smachine.

Here i stopped messenger service and started the netbios application.... Please give me any suggession I can give 1000(thousand) points.


Roshmon
0
 
LVL 11

Expert Comment

by:alexo
ID: 8701221
more details needed
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 8705364
Yeah...

After changing my net name to 15 chars, it is working. But the sender getting some error messages with number 2136 ...?

Any idea to send ACK to the sender...?

Roshmon
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 8729867
Hi alexo,

    I'm waiting for your commnet, If i got the answer, I can assign 1000 points to you....

Roshmon
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 8737485
Hi alexo,

   I'm waiting for your commnet, If i got the answer, I can assign 1000 points to you....

Roshmon
0
 
LVL 11

Expert Comment

by:alexo
ID: 8737558
Roshmon, please explain your problem IN AS MUCH DETAIL AS POSSIBLE.
If you have source code, please include the relevent parts.
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 8737592
This is the code which I tested for the message receive....
I'm geting the message, but in  the sender side, they getting 2136 error.... No delay is thare...When I perform NCBHANGUP, immediately they getting this error

      NCB ncb;
      BYTE lsn;
      const int SIZE = 1024;
      const char *NAME = "ROSHAN         ";
      unsigned char buff[SIZE];
      int i;

      //reset the adapter
      ZeroMemory(&ncb, sizeof(NCB));
      ncb.ncb_command = NCBRESET;
      ncb.ncb_lsn = 0;
      ncb.ncb_callname[0] = '\ff';
      ncb.ncb_callname[1] = '\ff';
      ncb.ncb_callname[0] = '\0';

      Netbios(&ncb);

      if(ncb.ncb_retcode != NRC_GOODRET)
      {
            cerr << "Error code: " << (int)ncb.ncb_retcode << '\n';
            Sleep(3000);
            return;
      }
      else cerr << "Reset OK\n";

      //add name
      ZeroMemory(&ncb, sizeof(NCB));
      ncb.ncb_command = NCBADDNAME;
      lstrcpy((char*)ncb.ncb_name, NAME);
      ncb.ncb_name[15] = (unsigned char)'\03';
      ncb.ncb_buffer = buff;
      ncb.ncb_length = SIZE;

      Netbios(&ncb);

      if(ncb.ncb_retcode != NRC_GOODRET)
      {
            cerr << "Error code: " << (int)ncb.ncb_retcode << '\n';
            Sleep(3000);
            return;
      }
      else cerr << "Name successfully added\n";

      for(;;)
      {
            cerr << "Listening...\n";
            //listen for incoming calls
            ZeroMemory(&ncb, sizeof(NCB));
            ncb.ncb_command = NCBLISTEN;
            //ncb.ncb_callname[0] = '*'; //from any name
            lstrcpy((char*)ncb.ncb_callname, "*              \0");
            lstrcpy((char*)ncb.ncb_name, NAME);
            ncb.ncb_name[15] = (unsigned char)'\03';
            ncb.ncb_rto = 0;
            ncb.ncb_sto = 0;

            Netbios(&ncb);

            lsn = ncb.ncb_lsn;

            if(ncb.ncb_retcode != NRC_GOODRET)
            {
                  cerr << "Error code: " << (int)ncb.ncb_retcode << '\n';
                  continue;
            }

            //display caller's name
            TRACE("WHAM!! \"");
            for(i=0; i<NCBNAMSZ; i++)
                  TRACE("%c", ncb.ncb_callname[i]);
            TRACE("\" calling in\n");

            //recieve data
            ZeroMemory(&ncb, sizeof(NCB));
            ncb.ncb_command = NCBRECV;
            ncb.ncb_buffer = buff;
            ncb.ncb_length = SIZE;
            ncb.ncb_lsn = lsn;

            int nRet = Netbios(&ncb);

            if(ncb.ncb_retcode != NRC_GOODRET)
            {
                  cerr << "Error code: " << (int)ncb.ncb_retcode << '\n';
                  continue;
            }

            //output the data
            for(i=0; i<ncb.ncb_length; i++)
                  TRACE("%c", buff[i]);
            TRACE("\n");

            //hang up
            ZeroMemory(&ncb, sizeof(NCB));
            ncb.ncb_command = NCBHANGUP;
            ncb.ncb_lsn = lsn;

            nRet = Netbios(&ncb);
      }

Roshmon
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 8737958
Hi alexo,

    Any clues?

Roshmon
0
 
LVL 11

Expert Comment

by:alexo
ID: 8746032
Make sure the message you send is in the following format:

        From\0To\0Message\0


However, I don't think that using NetBIOS NCBs are a good idea, too low level and too many things can go wrong.
I suggest you use Mailslots instead.  Much cleaner interface.

There are several resources on the net with explanations and source examples.  Try:
- http://www.ticz.com/homes/users/nlewis/HTML/Software_Development/MISC/WinPopupEx.htm
- http://www.codeguru.com/mfc/comments/26455.shtml
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 8746261
Hi Alexo,

    I Have NO Problems in sending messages.... Only in receiving message. I can't use mailslot in that messngr slot, becoz, my Windows Messenger service is waiting exclusivly on that. So I have to stop messenger. Stopping messenger removes my net name.... thats Y  I 'm using NetBios for reading message....


Roshmon
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 8749878
Hi alexo,

  I got the answer. Collect your points

  http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_20652323.html

Roshmon
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question