CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Thread: Net Send

  1. #1
    Join Date
    Aug 2003
    Posts
    938

    Net Send

    Hello.
    i use the system("net send ...") as a messager service...but they show from where the message came...how can i cut that out
    ?

  2. #2
    Join Date
    Nov 2002
    Location
    Devon, UK
    Posts
    212
    Use NetMessageBufferSend net API call and pass an empty string as the fromname (3rd) param.

    HTH,
    Toot
    Some cause happiness wherever they go; others, whenever they go.

  3. #3
    Join Date
    Aug 2003
    Posts
    938
    here is code :
    char adrip[]="192.168.0.2";
    char message[]="salut";
    NetMessageBufferSend((LPCWSTR)adrip, (LPCWSTR)message, NULL, (LPBYTE)message, strlen(message));
    and when i use it it...does nothing...did i forget something?
    Last edited by Quell; April 28th, 2004 at 07:18 PM.

  4. #4
    Join Date
    Aug 2003
    Posts
    938
    eh..in addition, i need this to work in console..i got several example of this in mfc and w32api....
    but i need this in console...
    here is the code i have...but it does nothing...


    #include <iostream>
    #include <windows.h>
    #include <lm.h>
    using namespace std;
    int main(int argc, char *argv[])
    {
    char adrip[]="64.229.144.132";
    char message[]="test";
    NetMessageBufferSend((LPCWSTR)adrip, (LPCWSTR)message, NULL, (LPBYTE)message, strlen(message));
    system("pause");
    return 0;
    }
    thx in advance

  5. #5
    Join Date
    Apr 2004
    Posts
    15
    Originally posted by Quell
    eh..in addition, i need this to work in console..i got several example of this in mfc and w32api....
    but i need this in console...
    here is the code i have...but it does nothing...


    #include <iostream>
    #include <windows.h>
    #include <lm.h>
    using namespace std;
    int main(int argc, char *argv[])
    {
    char adrip[]="64.229.144.132";
    char message[]="test";
    NetMessageBufferSend((LPCWSTR)adrip, (LPCWSTR)message, NULL, (LPBYTE)message, strlen(message));
    system("pause");
    return 0;
    }
    thx in advance
    Salut,

    How about your error in the previous post ? Did you solve it or you post this code for us to check and give you the whole answer ?
    How about netapi32 linking problem ?

    You can search the net for "NetMessageBufferSend@20", i dont know if you did that, give it a try if not.

    Fiona

  6. #6
    Join Date
    Nov 2002
    Location
    Devon, UK
    Posts
    212
    Firstly, you've done an unsafe type cast on your IP address string and your message string. You can't just cast from a char* to a wchar_t* (LPCWSTR). If you're in COM-world, just use the ATL A2CW() macro (see string conversion macros in MSDN). If you're just a small console app, which it sounds like you might be, you'll need to look at MultiByteToWideChar API and its friends.

    Secondly, it doesn't look like you can put any old string in the "From", however given correct permissions you can make it look like the message came from the receiving machine (for example), or you could have a "message" server that processes the netsend messages:
    Code:
            LPCWSTR wszTo = L"machine";
            NET_API_STATUS stat = ::NetMessageBufferSend(wszTo, wszTo, NULL, (BYTE*)L"Hello", 6 * sizeof(wchar_t));
            if (stat != NERR_Success)
            {
                wcerr << L"ERROR: " << stat;
            }
    (not meant to be pretty but you should get the idea)

    HTH,
    Toot
    Some cause happiness wherever they go; others, whenever they go.

  7. #7
    Join Date
    Aug 2003
    Posts
    938
    yes, i corrected the .lib problem and that took care of te error...and yes, it is supoused to be nothing in the from filed...i want it to be anonymous yet....
    so yo think the problem is in the conversions?
    ok..i will try that
    Edit:
    I tried the
    LPCWSTR wstrAdress=A2CW(adrip);
    but the A2CW is undefined...isn't it just for MFC and ATL?
    cuz i am using DEc-cpp....
    Last edited by Quell; April 29th, 2004 at 07:03 AM.

  8. #8
    Join Date
    Aug 2003
    Posts
    938
    Hey, i got the funciton done, and it workes, but it sends only over the inter net, i need it to be
    able to send over lan...any ideas?

  9. #9
    Join Date
    Dec 2001
    Location
    Ontario, Canada
    Posts
    2,236
    I've posted an example of this before using mailslots. You basically just need to write to the correct mail slot on the target machine.

  10. #10
    Join Date
    Apr 1999
    Posts
    9

    Could you post the working version?

    Could anyone post a working version of the above,including sending messages in a LAN,or at least in a LAN knowing only the IPs....

    Thank you in advanced.

  11. #11
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    [Moved thread]

  12. #12
    Join Date
    Aug 2003
    Posts
    938
    ok , what is mailslot and how do i use it?

  13. #13
    Join Date
    Jun 2004
    Posts
    3

    getting info from windows messenger popup window

    I'm writing a VB6 net send GUI that works like msn messengers chat window. The only problem is that I can't figure out a way to get the data from the popup window into my GUI's display. I know that messenger uses mailslots, but I'm not sure how to use VB to access the correct mailslot to retrieve the data for the current message. Anyone have suggestions??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured