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
?
Printable View
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
?
Use NetMessageBufferSend net API call and pass an empty string as the fromname (3rd) param.
HTH,
Toot
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?
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,Quote:
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
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
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:
(not meant to be pretty but you should get the idea)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;
}
HTH,
Toot
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....
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?
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.
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.
[Moved thread]
ok , what is mailslot and how do i use it?
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??