Solved

Windows NT Messenger Service

Posted on 1998-04-13
21
248 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
Comment Utility
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
Comment Utility
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 80 total points
Comment Utility
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
 
LVL 11

Expert Comment

by:alexo
Comment Utility
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
Comment Utility
0
 

Author Comment

by:baluchi
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Oh sorry.  3 months old daughter == sleepless nights == tired eyes.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 23

Expert Comment

by:Roshan Davis
Comment Utility
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
Comment Utility
more details needed
0
 
LVL 23

Expert Comment

by:Roshan Davis
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Hi alexo,

    Any clues?

Roshmon
0
 
LVL 11

Expert Comment

by:alexo
Comment Utility
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
Comment Utility
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
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now