Link to home
Start Free TrialLog in
Avatar of baluchi
baluchi

asked on

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.
Avatar of alexo
alexo
Flag of Antarctica image

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...)

Avatar of baluchi
baluchi

ASKER

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?

ASKER CERTIFIED SOLUTION
Avatar of alexo
alexo
Flag of Antarctica image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of baluchi

ASKER

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.
Avatar of baluchi

ASKER

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?
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 :-)
Avatar of baluchi

ASKER

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.
Oh sorry.  3 months old daughter == sleepless nights == tired eyes.
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
more details needed
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
Hi alexo,

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

Roshmon
Hi alexo,

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

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

    Any clues?

Roshmon
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
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
Hi alexo,

  I got the answer. Collect your points

  https://www.experts-exchange.com/questions/20652323/Points-for-alexo.html

Roshmon