• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

Windows NT Messenger Service

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
baluchi
Asked:
baluchi
  • 9
  • 8
  • 4
1 Solution
 
alexoCommented:
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
 
baluchiAuthor Commented:
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
 
alexoCommented:
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
alexoCommented:
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
 
alexoCommented:
0
 
baluchiAuthor Commented:
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
 
baluchiAuthor Commented:
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
 
alexoCommented:
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
 
baluchiAuthor Commented:
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
 
alexoCommented:
Oh sorry.  3 months old daughter == sleepless nights == tired eyes.
0
 
Roshan DavisCommented:
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
 
alexoCommented:
more details needed
0
 
Roshan DavisCommented:
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
 
Roshan DavisCommented:
Hi alexo,

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

Roshmon
0
 
Roshan DavisCommented:
Hi alexo,

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

Roshmon
0
 
alexoCommented:
Roshmon, please explain your problem IN AS MUCH DETAIL AS POSSIBLE.
If you have source code, please include the relevent parts.
0
 
Roshan DavisCommented:
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
 
Roshan DavisCommented:
Hi alexo,

    Any clues?

Roshmon
0
 
alexoCommented:
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
 
Roshan DavisCommented:
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
 
Roshan DavisCommented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 9
  • 8
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now